save
This commit is contained in:
parent
24f6019d1b
commit
852c240113
226
swa/ic/active.ic.min.js
vendored
Normal file
226
swa/ic/active.ic.min.js
vendored
Normal file
@ -0,0 +1,226 @@
|
||||
function check(v, re, msg) {
|
||||
if (!re.test(v)) {
|
||||
alert(msg)
|
||||
}
|
||||
}
|
||||
|
||||
function padPkcs7(data) {
|
||||
|
||||
var d = data.length % 16;
|
||||
d = 16 - d;
|
||||
var arr = Array.from(data)
|
||||
for (var i = 0; i < d; i++) {
|
||||
arr.push(d)
|
||||
}
|
||||
return arr;
|
||||
}
|
||||
|
||||
function stripPcks7(data) {
|
||||
var arr = Array.from(data)
|
||||
var padder = arr[arr.length - 1];
|
||||
return arr.slice(0, arr.length - padder);
|
||||
}
|
||||
|
||||
function ecb(bytes, cb) {
|
||||
var ret = []
|
||||
for (var i = 0; i < bytes.length; i += 16) {
|
||||
var d = bytes.slice(i, i + 16);
|
||||
var en = cb(d)
|
||||
ret = ret.concat(Array.from(en))
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
function stringToHex(str){
|
||||
var val = "";
|
||||
for (var i = 0; i < str.length; i++) {
|
||||
var v = str.charCodeAt(i).toString(16);
|
||||
if ( v.length < 2 ) {
|
||||
v = "0" + v;
|
||||
}
|
||||
val += v;
|
||||
}
|
||||
return val
|
||||
}
|
||||
|
||||
function hexToString(hex){
|
||||
var arr = hex.split("")
|
||||
var out = ""
|
||||
for (var i = 0; i < arr.length / 2; i++) {
|
||||
var tmp = "0x" + arr[i * 2] + arr[i * 2 + 1]
|
||||
var charValue = String.fromCharCode(tmp);
|
||||
out += charValue
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
class ActiveIC {
|
||||
constructor() {
|
||||
this.server = "ws://127.0.0.1:12322/active";
|
||||
this.waitMap = {}
|
||||
|
||||
}
|
||||
|
||||
__debug(...str) {
|
||||
if (window.active_debug) {
|
||||
console.log(...str)
|
||||
}
|
||||
}
|
||||
|
||||
connect() {
|
||||
this.__debug("connect")
|
||||
var _this = this;
|
||||
try {
|
||||
|
||||
if (this.sock) {
|
||||
this.sock.onclose = function () {
|
||||
}
|
||||
this.sock.close()
|
||||
}
|
||||
|
||||
this.sock = new WebSocket(this.server);
|
||||
this.__debug("sock")
|
||||
this.sock.onopen = function () {
|
||||
_this.__debug("open");
|
||||
_this.sock.isopened = true;
|
||||
_this.sock.onmessage = function (e) {
|
||||
_this.__debug(e.data)
|
||||
var ret = JSON.parse(e.data);
|
||||
|
||||
var cb = _this.waitMap[ret.id]
|
||||
cb && cb(ret)
|
||||
}
|
||||
};
|
||||
|
||||
this.sock.onclose = function () {
|
||||
_this.sock.isopened = false;
|
||||
_this.__debug("close");
|
||||
_this.reconnect();
|
||||
};
|
||||
|
||||
// this.sock.onerror = function () {
|
||||
// _this.sock.isopened = false;
|
||||
// this.__debug("onerror");
|
||||
// _this.reconnect();
|
||||
// };
|
||||
|
||||
} catch (e) {
|
||||
_this.__debug("onerror");
|
||||
_this.reconnect();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
reconnect() {
|
||||
this.__debug("reconnect")
|
||||
var _this = this;
|
||||
|
||||
if (_this.sock && _this.sock.isopened) {
|
||||
this.__debug("miss")
|
||||
return
|
||||
}
|
||||
|
||||
setTimeout(function () {
|
||||
_this.connect();
|
||||
}, 3000);
|
||||
}
|
||||
|
||||
__send(cmd, param, cb) {
|
||||
var id = (Math.random() + "").substr(2);
|
||||
this.sock.send(
|
||||
JSON.stringify({
|
||||
id: id,
|
||||
cmd: cmd,
|
||||
param: param
|
||||
})
|
||||
);
|
||||
if (cb) {
|
||||
this.waitMap[id] = cb;
|
||||
}
|
||||
}
|
||||
|
||||
__check(v, re, msg, reject) {
|
||||
if (!re.test(v)) {
|
||||
reject && reject({
|
||||
msg,
|
||||
code: "C0"
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
readText(addr, len) {
|
||||
var _this = this;
|
||||
return new Promise(function (resolve, reject) {
|
||||
|
||||
if (!_this.sock || !_this.sock.isopened) {
|
||||
reject({
|
||||
code: "CB",
|
||||
msg: "Active 通信失败"
|
||||
})
|
||||
}
|
||||
|
||||
_this.__check(addr, /\d{1,2}/g, "用户编号填写错误!", reject);
|
||||
_this.__check(len, /\d{1,2}/g, "用户类型填写错误!", reject);
|
||||
|
||||
_this.__send("read", {
|
||||
addr, len
|
||||
}, function (ret) {
|
||||
if (ret.code === "00") {
|
||||
resolve(ret)
|
||||
} else {
|
||||
reject(ret)
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
writeText(addr, data) {
|
||||
return this.writeHex(addr, stringToHex( data ))
|
||||
}
|
||||
writeHex(addr, data) {
|
||||
var _this = this;
|
||||
return new Promise(function (resolve, reject) {
|
||||
|
||||
if (!_this.sock || !_this.sock.isopened) {
|
||||
reject({
|
||||
code: "CB",
|
||||
msg: "Active 通信失败"
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
_this.__check(addr, /\d{1,2}/g, "地址填写错误!", reject);
|
||||
_this.__check(data, /^([A-Fa-f0-9][A-Fa-f0-9])+$/g, "数据填写错误!", reject);
|
||||
|
||||
_this.__send("write", {
|
||||
addr, data
|
||||
}, function (ret) {
|
||||
if (ret.code === "00") {
|
||||
resolve(ret)
|
||||
} else {
|
||||
reject(ret)
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 检测通过返回 true
|
||||
* 检测不通过返回 fase
|
||||
*/
|
||||
ActiveIC.checkSupport = function () {
|
||||
try {
|
||||
if (!!window.WebSocket && window.WebSocket.prototype.send) {
|
||||
return true;
|
||||
} else {
|
||||
console.error("您的浏览器不支持!")
|
||||
return false;
|
||||
}
|
||||
} catch (e) {
|
||||
console.error("当前环境不支持!", e)
|
||||
return false;
|
||||
}
|
||||
}
|
BIN
swa/ic/active_ic_setup.exe
Normal file
BIN
swa/ic/active_ic_setup.exe
Normal file
Binary file not shown.
@ -143,26 +143,26 @@
|
||||
|
||||
<div class="line">
|
||||
<span>IC卡属主 (20h+1)</span>
|
||||
<input id="path" style="width: 300px; height: 1.06rem" type="text" value="\root\mana"
|
||||
placeholder="文件目录">
|
||||
<input id="path1" style="width: 300px; height: 1.06rem" type="text" value="" maxlength="2"
|
||||
placeholder="31/32/33">
|
||||
</div>
|
||||
|
||||
<div class="line">
|
||||
<span>特征字串 (30h+16)</span>
|
||||
<input id="path" style="width: 300px; height: 1.06rem" type="text" value="\root\mana"
|
||||
placeholder="文件目录">
|
||||
<input id="path2" style="width: 300px; height: 1.06rem" type="text" maxlength="32" value=""
|
||||
placeholder="特征字符串">
|
||||
</div>
|
||||
|
||||
<div class="line">
|
||||
<span>主密钥分量 (40h+5)</span>
|
||||
<input id="path" style="width: 300px; height: 1.06rem" type="text" value="\root\mana"
|
||||
placeholder="文件目录">
|
||||
<input id="path3" style="width: 300px; height: 1.06rem" type="text" value=""
|
||||
placeholder="保留">
|
||||
</div>
|
||||
|
||||
<div class="line">
|
||||
<span>LMK0 (50h+16)</span>
|
||||
<input id="path" style="width: 300px; height: 1.06rem" type="text" value="\root\mana"
|
||||
placeholder="文件目录">
|
||||
<input id="path4" style="width: 300px; height: 1.06rem" type="text" value=""
|
||||
placeholder="保留">
|
||||
</div>
|
||||
|
||||
<div class="line">
|
||||
@ -172,8 +172,9 @@
|
||||
</div>
|
||||
|
||||
|
||||
<button>读取所有</button>
|
||||
<button>写入所有</button>
|
||||
<button id="btn_read">读取所有</button>
|
||||
<button id="btn_write">写入所有</button>
|
||||
<button id="btn_clear">清空</button>
|
||||
|
||||
</div>
|
||||
|
||||
@ -181,7 +182,7 @@
|
||||
|
||||
<ul>
|
||||
<li>
|
||||
<h4 style="color: var(--mainColor);">V1.0 <span style="font-size: 0.5rem; font-weight: normal; cursor: pointer">(点击下载)</span> </h4>
|
||||
<h4 style="color: var(--mainColor);">V1.0 <a href="./active_ic_setup.exe" style="font-size: 0.5rem; font-weight: normal; cursor: pointer">(点击下载)</a> </h4>
|
||||
<p>【2022年12月22日】</p>
|
||||
<p>第一个发行版本</p>
|
||||
</li>
|
||||
@ -199,8 +200,8 @@
|
||||
<!-- UKey 支持, 共 3 个 js-->
|
||||
<!-- jquery -->
|
||||
<script type="text/javascript" src="./jquery.min.js"></script>
|
||||
<script type="text/javascript" src="./fiseckey.js"></script>
|
||||
<script type="text/javascript" src="./ukey.js"></script>
|
||||
<script type="text/javascript" src="./active.ic.min.js"></script>
|
||||
|
||||
|
||||
|
||||
<!-- 演示程序 -->
|
||||
@ -209,85 +210,9 @@
|
||||
<script type="application/javascript" src="tools.js"></script>
|
||||
<script type="application/javascript">
|
||||
$(function () {
|
||||
function refresh() {
|
||||
var list = window.UKey.enumDevByArray()
|
||||
if (list) {
|
||||
var ll = list.split("|");
|
||||
var options = ""
|
||||
for (var i = 0; i < ll.length; i++) {
|
||||
var value = ll[i].split(",")[0]
|
||||
options += "<option value =\"" + value + "\">" + ll[i] + "</option>"
|
||||
}
|
||||
$("#ukeys").html(options);
|
||||
}
|
||||
}
|
||||
|
||||
refresh();
|
||||
|
||||
$("#btn_refresh").click(function () {
|
||||
refresh()
|
||||
success("刷新成功")
|
||||
})
|
||||
|
||||
$("#btn_list_path").click(function () {
|
||||
var path = $("#path").val();
|
||||
try {
|
||||
var ret = window.UKey.enumDir(path)
|
||||
|
||||
var out = ""
|
||||
for (var i = 0; i < ret.folders.length; i++) {
|
||||
out += "文件夹:\t" + ret.folders[i] + "\r\n"
|
||||
}
|
||||
|
||||
for (var i = 0; i < ret.files.length; i++) {
|
||||
out += "文件:\t" + ret.files[i] + "\r\n"
|
||||
}
|
||||
|
||||
$("#ta_files").text(out)
|
||||
success("枚举成功")
|
||||
|
||||
} catch (e) {
|
||||
alert("枚举失败:" + e.message)
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
$("#login2").click(function () {
|
||||
var pwd2 = $("#pwd2").val();
|
||||
check(pwd2, /\d{8}/, "口令输入错误")
|
||||
var ukey = $("#ukeys").val();
|
||||
|
||||
try {
|
||||
window.UKey.admin(ukey, pwd2)
|
||||
success("登录成功")
|
||||
} catch (e) {
|
||||
alert("登录失败:" + e.message)
|
||||
}
|
||||
})
|
||||
|
||||
$("#login2_def").click(function () {
|
||||
$("#pwd2").val("12345678");
|
||||
$("#login2").click()
|
||||
})
|
||||
|
||||
$("#login").click(function () {
|
||||
var pwd1 = $("#pwd1").val();
|
||||
check(pwd1, /\d{8}/, "口令输入错误")
|
||||
var ukey = $("#ukeys").val();
|
||||
|
||||
try {
|
||||
window.UKey.login(ukey, pwd1)
|
||||
success("登录成功")
|
||||
} catch (e) {
|
||||
alert("登录失败:" + e.message)
|
||||
}
|
||||
})
|
||||
|
||||
$("#login_def").click(function () {
|
||||
$("#pwd1").val("12345678");
|
||||
$("#login").click()
|
||||
})
|
||||
|
||||
var ic = new ActiveIC();
|
||||
ic.connect()
|
||||
|
||||
$("#btn_nameplate_clear").click(function () {
|
||||
$("#manufactor").val("");
|
||||
@ -295,25 +220,11 @@
|
||||
$("#customer").val("");
|
||||
})
|
||||
|
||||
$("#btn_read").click(function () {
|
||||
|
||||
var filepath = $("#filepath").val()
|
||||
var idx = filepath.lastIndexOf("\\")
|
||||
var folder = filepath.substr(0, idx)
|
||||
var file = filepath.substr(idx + 1)
|
||||
var txt = window.UKey.readFile(folder, file);
|
||||
$("#ta_txt").text(JSON.stringify(txt, null, 4))
|
||||
})
|
||||
|
||||
$("#btn_write").click(function () {
|
||||
alert("暂不开放")
|
||||
})
|
||||
|
||||
$("#btn_nameplate_tmp_load").click(function () {
|
||||
var def = {
|
||||
manufactor: "sunyard",
|
||||
system: "hsm",
|
||||
customer: "ICBC"
|
||||
manufactor: "SUNYARD@",
|
||||
system: "PAYVER50",
|
||||
customer: "ICBC-ZJ"
|
||||
}
|
||||
$("#manufactor").val(def.manufactor);
|
||||
$("#system").val(def.system);
|
||||
@ -323,20 +234,23 @@
|
||||
$("#btn_nameplate_read").click(function () {
|
||||
|
||||
try {
|
||||
var txt = window.UKey.catRelease();
|
||||
var def = Object.assign({
|
||||
manufactor: "",
|
||||
system: "",
|
||||
customer: ""
|
||||
}, txt)
|
||||
|
||||
$("#manufactor").val(def.manufactor);
|
||||
$("#system").val(def.system);
|
||||
$("#customer").val(def.customer);
|
||||
ic.readText(0, 32)
|
||||
|
||||
.then(function (def){
|
||||
def = hexToString( def.data )
|
||||
$("#manufactor").val(def.substr(0, 8));
|
||||
$("#system").val(def.substr(8, 8));
|
||||
$("#customer").val(def.substr(16, 16));
|
||||
|
||||
success("返显成功")
|
||||
})
|
||||
.catch(function (e) {
|
||||
alert("返显失败:" + e.msg)
|
||||
})
|
||||
|
||||
} catch (e) {
|
||||
alert("返显失败:" + e.message)
|
||||
alert("返显失败:" + e.msg)
|
||||
}
|
||||
})
|
||||
|
||||
@ -346,9 +260,9 @@
|
||||
|
||||
var json = localStorage.getItem("tmp")
|
||||
var def = {
|
||||
manufactor: "sunyard",
|
||||
system: "hsm",
|
||||
customer: "ICBC"
|
||||
manufactor: "SUNYARD@",
|
||||
system: "PAYVER50",
|
||||
customer: "ICBC-ZJ"
|
||||
}
|
||||
try {
|
||||
def = JSON.parse(json)
|
||||
@ -380,28 +294,71 @@
|
||||
customer: $("#customer").val()
|
||||
}
|
||||
|
||||
check(def.manufactor, /\w+/, "厂家标记填写错误")
|
||||
check(def.system, /\w+/, "系统信息填写错误")
|
||||
check(def.customer, /\w+/, "客户信息填写错误")
|
||||
check(def.manufactor, /[\w|@]{8}/, "厂家标记填写错误")
|
||||
check(def.system, /\w{8}/, "系统信息填写错误")
|
||||
check(def.customer, /[\w|\|\-|\-]{7,16}/, "客户信息填写错误")
|
||||
|
||||
try {
|
||||
window.UKey.release(def)
|
||||
|
||||
def.customer += " "
|
||||
def.customer = def.customer.substr(0, 16)
|
||||
|
||||
var info = def.manufactor + def.system + def.customer
|
||||
|
||||
ic.writeText(0, info).then(function () {
|
||||
success("发行成功")
|
||||
}).catch(function (e) {
|
||||
alert("发行失败:" + e.msg)
|
||||
});
|
||||
} catch (e) {
|
||||
alert("发行失败:" + e.message)
|
||||
console.log( e )
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
|
||||
$("#reset").click(function () {
|
||||
alert("暂不开放")
|
||||
|
||||
$("#btn_clear").click(function () {
|
||||
$("#path1").val("");
|
||||
$("#path2").val("");
|
||||
})
|
||||
$("#update1").click(function () {
|
||||
alert("暂不开放")
|
||||
|
||||
$("#btn_read").click(function () {
|
||||
ic.readText(0x20, 1)
|
||||
.then(function (def){
|
||||
$("#path1").val(def.data);
|
||||
return ic.readText(0x30, 16)
|
||||
})
|
||||
.then(function (def){
|
||||
$("#path2").val(def.data);
|
||||
success("读取成功")
|
||||
})
|
||||
.catch(function (e) {
|
||||
alert("读取失败:" + e.msg)
|
||||
})
|
||||
})
|
||||
$("#btn_write").click(function () {
|
||||
var path1 = $("#path1").val();
|
||||
if ( path1 != "31"
|
||||
&& path1 != "32"
|
||||
&& path1 != "33") {
|
||||
alert("IC卡属主填写错误")
|
||||
return
|
||||
}
|
||||
|
||||
var path2 = $("#path2").val();
|
||||
check(path2, /^([A-Fa-f0-9][A-Fa-f0-9]){16}$/g, "特征字串填充错误")
|
||||
|
||||
ic.writeHex(0x20, path1)
|
||||
.then(function (def){
|
||||
return ic.writeHex(0x30, path2)
|
||||
})
|
||||
.then(function (def){
|
||||
success("写入成功")
|
||||
})
|
||||
.catch(function (e) {
|
||||
alert("写入失败:" + e.msg)
|
||||
})
|
||||
$("#update2").click(function () {
|
||||
alert("暂不开放")
|
||||
})
|
||||
|
||||
})
|
||||
|
@ -119,11 +119,11 @@
|
||||
readonly></textarea>
|
||||
|
||||
|
||||
<input id="filepath" style="width: 300px; height: 1.06rem" type="text" value="\root\mana\name"
|
||||
<input id="filepath" style="width: 260px; height: 1.06rem" type="text" value="\root\mana\name"
|
||||
placeholder="文件">
|
||||
<button id="btn_read" style="margin-right: 0.5rem">读</button>
|
||||
<button id="btn_write" style="margin-right: 1rem">写</button>
|
||||
<button id="btn_delete" style="margin-right: 1rem">删</button>
|
||||
<button id="btn_write" style="margin-right: 0.5rem">写</button>
|
||||
<button id="btn_delete" style="margin-right: 0.5rem">删</button>
|
||||
|
||||
<textarea id="ta_txt" style="display: block; margin: 1rem 0; width: 375px; height: 100px;"
|
||||
></textarea>
|
||||
@ -297,7 +297,7 @@
|
||||
|
||||
|
||||
var txt = $("#ta_txt").val();
|
||||
window.UKey.de(folder, file, txt);
|
||||
window.UKey.writeFile(folder, file, txt);
|
||||
success("写入成功")
|
||||
} catch (e) {
|
||||
alert("写入失败:" + e.message)
|
||||
|
226
www/swa/ic/active.ic.min.js
vendored
Normal file
226
www/swa/ic/active.ic.min.js
vendored
Normal file
@ -0,0 +1,226 @@
|
||||
function check(v, re, msg) {
|
||||
if (!re.test(v)) {
|
||||
alert(msg)
|
||||
}
|
||||
}
|
||||
|
||||
function padPkcs7(data) {
|
||||
|
||||
var d = data.length % 16;
|
||||
d = 16 - d;
|
||||
var arr = Array.from(data)
|
||||
for (var i = 0; i < d; i++) {
|
||||
arr.push(d)
|
||||
}
|
||||
return arr;
|
||||
}
|
||||
|
||||
function stripPcks7(data) {
|
||||
var arr = Array.from(data)
|
||||
var padder = arr[arr.length - 1];
|
||||
return arr.slice(0, arr.length - padder);
|
||||
}
|
||||
|
||||
function ecb(bytes, cb) {
|
||||
var ret = []
|
||||
for (var i = 0; i < bytes.length; i += 16) {
|
||||
var d = bytes.slice(i, i + 16);
|
||||
var en = cb(d)
|
||||
ret = ret.concat(Array.from(en))
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
function stringToHex(str){
|
||||
var val = "";
|
||||
for (var i = 0; i < str.length; i++) {
|
||||
var v = str.charCodeAt(i).toString(16);
|
||||
if ( v.length < 2 ) {
|
||||
v = "0" + v;
|
||||
}
|
||||
val += v;
|
||||
}
|
||||
return val
|
||||
}
|
||||
|
||||
function hexToString(hex){
|
||||
var arr = hex.split("")
|
||||
var out = ""
|
||||
for (var i = 0; i < arr.length / 2; i++) {
|
||||
var tmp = "0x" + arr[i * 2] + arr[i * 2 + 1]
|
||||
var charValue = String.fromCharCode(tmp);
|
||||
out += charValue
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
class ActiveIC {
|
||||
constructor() {
|
||||
this.server = "ws://127.0.0.1:12322/active";
|
||||
this.waitMap = {}
|
||||
|
||||
}
|
||||
|
||||
__debug(...str) {
|
||||
if (window.active_debug) {
|
||||
console.log(...str)
|
||||
}
|
||||
}
|
||||
|
||||
connect() {
|
||||
this.__debug("connect")
|
||||
var _this = this;
|
||||
try {
|
||||
|
||||
if (this.sock) {
|
||||
this.sock.onclose = function () {
|
||||
}
|
||||
this.sock.close()
|
||||
}
|
||||
|
||||
this.sock = new WebSocket(this.server);
|
||||
this.__debug("sock")
|
||||
this.sock.onopen = function () {
|
||||
_this.__debug("open");
|
||||
_this.sock.isopened = true;
|
||||
_this.sock.onmessage = function (e) {
|
||||
_this.__debug(e.data)
|
||||
var ret = JSON.parse(e.data);
|
||||
|
||||
var cb = _this.waitMap[ret.id]
|
||||
cb && cb(ret)
|
||||
}
|
||||
};
|
||||
|
||||
this.sock.onclose = function () {
|
||||
_this.sock.isopened = false;
|
||||
_this.__debug("close");
|
||||
_this.reconnect();
|
||||
};
|
||||
|
||||
// this.sock.onerror = function () {
|
||||
// _this.sock.isopened = false;
|
||||
// this.__debug("onerror");
|
||||
// _this.reconnect();
|
||||
// };
|
||||
|
||||
} catch (e) {
|
||||
_this.__debug("onerror");
|
||||
_this.reconnect();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
reconnect() {
|
||||
this.__debug("reconnect")
|
||||
var _this = this;
|
||||
|
||||
if (_this.sock && _this.sock.isopened) {
|
||||
this.__debug("miss")
|
||||
return
|
||||
}
|
||||
|
||||
setTimeout(function () {
|
||||
_this.connect();
|
||||
}, 3000);
|
||||
}
|
||||
|
||||
__send(cmd, param, cb) {
|
||||
var id = (Math.random() + "").substr(2);
|
||||
this.sock.send(
|
||||
JSON.stringify({
|
||||
id: id,
|
||||
cmd: cmd,
|
||||
param: param
|
||||
})
|
||||
);
|
||||
if (cb) {
|
||||
this.waitMap[id] = cb;
|
||||
}
|
||||
}
|
||||
|
||||
__check(v, re, msg, reject) {
|
||||
if (!re.test(v)) {
|
||||
reject && reject({
|
||||
msg,
|
||||
code: "C0"
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
readText(addr, len) {
|
||||
var _this = this;
|
||||
return new Promise(function (resolve, reject) {
|
||||
|
||||
if (!_this.sock || !_this.sock.isopened) {
|
||||
reject({
|
||||
code: "CB",
|
||||
msg: "Active 通信失败"
|
||||
})
|
||||
}
|
||||
|
||||
_this.__check(addr, /\d{1,2}/g, "用户编号填写错误!", reject);
|
||||
_this.__check(len, /\d{1,2}/g, "用户类型填写错误!", reject);
|
||||
|
||||
_this.__send("read", {
|
||||
addr, len
|
||||
}, function (ret) {
|
||||
if (ret.code === "00") {
|
||||
resolve(ret)
|
||||
} else {
|
||||
reject(ret)
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
writeText(addr, data) {
|
||||
return this.writeHex(addr, stringToHex( data ))
|
||||
}
|
||||
writeHex(addr, data) {
|
||||
var _this = this;
|
||||
return new Promise(function (resolve, reject) {
|
||||
|
||||
if (!_this.sock || !_this.sock.isopened) {
|
||||
reject({
|
||||
code: "CB",
|
||||
msg: "Active 通信失败"
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
_this.__check(addr, /\d{1,2}/g, "地址填写错误!", reject);
|
||||
_this.__check(data, /^([A-Fa-f0-9][A-Fa-f0-9])+$/g, "数据填写错误!", reject);
|
||||
|
||||
_this.__send("write", {
|
||||
addr, data
|
||||
}, function (ret) {
|
||||
if (ret.code === "00") {
|
||||
resolve(ret)
|
||||
} else {
|
||||
reject(ret)
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 检测通过返回 true
|
||||
* 检测不通过返回 fase
|
||||
*/
|
||||
ActiveIC.checkSupport = function () {
|
||||
try {
|
||||
if (!!window.WebSocket && window.WebSocket.prototype.send) {
|
||||
return true;
|
||||
} else {
|
||||
console.error("您的浏览器不支持!")
|
||||
return false;
|
||||
}
|
||||
} catch (e) {
|
||||
console.error("当前环境不支持!", e)
|
||||
return false;
|
||||
}
|
||||
}
|
BIN
www/swa/ic/active_ic_setup.exe
Normal file
BIN
www/swa/ic/active_ic_setup.exe
Normal file
Binary file not shown.
@ -143,26 +143,26 @@
|
||||
|
||||
<div class="line">
|
||||
<span>IC卡属主 (20h+1)</span>
|
||||
<input id="path" style="width: 300px; height: 1.06rem" type="text" value="\root\mana"
|
||||
placeholder="文件目录">
|
||||
<input id="path1" style="width: 300px; height: 1.06rem" type="text" value="" maxlength="2"
|
||||
placeholder="31/32/33">
|
||||
</div>
|
||||
|
||||
<div class="line">
|
||||
<span>特征字串 (30h+16)</span>
|
||||
<input id="path" style="width: 300px; height: 1.06rem" type="text" value="\root\mana"
|
||||
placeholder="文件目录">
|
||||
<input id="path2" style="width: 300px; height: 1.06rem" type="text" maxlength="32" value=""
|
||||
placeholder="特征字符串">
|
||||
</div>
|
||||
|
||||
<div class="line">
|
||||
<span>主密钥分量 (40h+5)</span>
|
||||
<input id="path" style="width: 300px; height: 1.06rem" type="text" value="\root\mana"
|
||||
placeholder="文件目录">
|
||||
<input id="path3" style="width: 300px; height: 1.06rem" type="text" value=""
|
||||
placeholder="保留">
|
||||
</div>
|
||||
|
||||
<div class="line">
|
||||
<span>LMK0 (50h+16)</span>
|
||||
<input id="path" style="width: 300px; height: 1.06rem" type="text" value="\root\mana"
|
||||
placeholder="文件目录">
|
||||
<input id="path4" style="width: 300px; height: 1.06rem" type="text" value=""
|
||||
placeholder="保留">
|
||||
</div>
|
||||
|
||||
<div class="line">
|
||||
@ -172,8 +172,9 @@
|
||||
</div>
|
||||
|
||||
|
||||
<button>读取所有</button>
|
||||
<button>写入所有</button>
|
||||
<button id="btn_read">读取所有</button>
|
||||
<button id="btn_write">写入所有</button>
|
||||
<button id="btn_clear">清空</button>
|
||||
|
||||
</div>
|
||||
|
||||
@ -181,7 +182,7 @@
|
||||
|
||||
<ul>
|
||||
<li>
|
||||
<h4 style="color: var(--mainColor);">V1.0 <span style="font-size: 0.5rem; font-weight: normal; cursor: pointer">(点击下载)</span> </h4>
|
||||
<h4 style="color: var(--mainColor);">V1.0 <a href="./active_ic_setup.exe" style="font-size: 0.5rem; font-weight: normal; cursor: pointer">(点击下载)</a> </h4>
|
||||
<p>【2022年12月22日】</p>
|
||||
<p>第一个发行版本</p>
|
||||
</li>
|
||||
@ -199,8 +200,8 @@
|
||||
<!-- UKey 支持, 共 3 个 js-->
|
||||
<!-- jquery -->
|
||||
<script type="text/javascript" src="./jquery.min.js"></script>
|
||||
<script type="text/javascript" src="./fiseckey.js"></script>
|
||||
<script type="text/javascript" src="./ukey.js"></script>
|
||||
<script type="text/javascript" src="./active.ic.min.js"></script>
|
||||
|
||||
|
||||
|
||||
<!-- 演示程序 -->
|
||||
@ -209,85 +210,9 @@
|
||||
<script type="application/javascript" src="tools.js"></script>
|
||||
<script type="application/javascript">
|
||||
$(function () {
|
||||
function refresh() {
|
||||
var list = window.UKey.enumDevByArray()
|
||||
if (list) {
|
||||
var ll = list.split("|");
|
||||
var options = ""
|
||||
for (var i = 0; i < ll.length; i++) {
|
||||
var value = ll[i].split(",")[0]
|
||||
options += "<option value =\"" + value + "\">" + ll[i] + "</option>"
|
||||
}
|
||||
$("#ukeys").html(options);
|
||||
}
|
||||
}
|
||||
|
||||
refresh();
|
||||
|
||||
$("#btn_refresh").click(function () {
|
||||
refresh()
|
||||
success("刷新成功")
|
||||
})
|
||||
|
||||
$("#btn_list_path").click(function () {
|
||||
var path = $("#path").val();
|
||||
try {
|
||||
var ret = window.UKey.enumDir(path)
|
||||
|
||||
var out = ""
|
||||
for (var i = 0; i < ret.folders.length; i++) {
|
||||
out += "文件夹:\t" + ret.folders[i] + "\r\n"
|
||||
}
|
||||
|
||||
for (var i = 0; i < ret.files.length; i++) {
|
||||
out += "文件:\t" + ret.files[i] + "\r\n"
|
||||
}
|
||||
|
||||
$("#ta_files").text(out)
|
||||
success("枚举成功")
|
||||
|
||||
} catch (e) {
|
||||
alert("枚举失败:" + e.message)
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
$("#login2").click(function () {
|
||||
var pwd2 = $("#pwd2").val();
|
||||
check(pwd2, /\d{8}/, "口令输入错误")
|
||||
var ukey = $("#ukeys").val();
|
||||
|
||||
try {
|
||||
window.UKey.admin(ukey, pwd2)
|
||||
success("登录成功")
|
||||
} catch (e) {
|
||||
alert("登录失败:" + e.message)
|
||||
}
|
||||
})
|
||||
|
||||
$("#login2_def").click(function () {
|
||||
$("#pwd2").val("12345678");
|
||||
$("#login2").click()
|
||||
})
|
||||
|
||||
$("#login").click(function () {
|
||||
var pwd1 = $("#pwd1").val();
|
||||
check(pwd1, /\d{8}/, "口令输入错误")
|
||||
var ukey = $("#ukeys").val();
|
||||
|
||||
try {
|
||||
window.UKey.login(ukey, pwd1)
|
||||
success("登录成功")
|
||||
} catch (e) {
|
||||
alert("登录失败:" + e.message)
|
||||
}
|
||||
})
|
||||
|
||||
$("#login_def").click(function () {
|
||||
$("#pwd1").val("12345678");
|
||||
$("#login").click()
|
||||
})
|
||||
|
||||
var ic = new ActiveIC();
|
||||
ic.connect()
|
||||
|
||||
$("#btn_nameplate_clear").click(function () {
|
||||
$("#manufactor").val("");
|
||||
@ -295,25 +220,11 @@
|
||||
$("#customer").val("");
|
||||
})
|
||||
|
||||
$("#btn_read").click(function () {
|
||||
|
||||
var filepath = $("#filepath").val()
|
||||
var idx = filepath.lastIndexOf("\\")
|
||||
var folder = filepath.substr(0, idx)
|
||||
var file = filepath.substr(idx + 1)
|
||||
var txt = window.UKey.readFile(folder, file);
|
||||
$("#ta_txt").text(JSON.stringify(txt, null, 4))
|
||||
})
|
||||
|
||||
$("#btn_write").click(function () {
|
||||
alert("暂不开放")
|
||||
})
|
||||
|
||||
$("#btn_nameplate_tmp_load").click(function () {
|
||||
var def = {
|
||||
manufactor: "sunyard",
|
||||
system: "hsm",
|
||||
customer: "ICBC"
|
||||
manufactor: "SUNYARD@",
|
||||
system: "PAYVER50",
|
||||
customer: "ICBC-ZJ"
|
||||
}
|
||||
$("#manufactor").val(def.manufactor);
|
||||
$("#system").val(def.system);
|
||||
@ -323,20 +234,23 @@
|
||||
$("#btn_nameplate_read").click(function () {
|
||||
|
||||
try {
|
||||
var txt = window.UKey.catRelease();
|
||||
var def = Object.assign({
|
||||
manufactor: "",
|
||||
system: "",
|
||||
customer: ""
|
||||
}, txt)
|
||||
|
||||
$("#manufactor").val(def.manufactor);
|
||||
$("#system").val(def.system);
|
||||
$("#customer").val(def.customer);
|
||||
ic.readText(0, 32)
|
||||
|
||||
.then(function (def){
|
||||
def = hexToString( def.data )
|
||||
$("#manufactor").val(def.substr(0, 8));
|
||||
$("#system").val(def.substr(8, 8));
|
||||
$("#customer").val(def.substr(16, 16));
|
||||
|
||||
success("返显成功")
|
||||
})
|
||||
.catch(function (e) {
|
||||
alert("返显失败:" + e.msg)
|
||||
})
|
||||
|
||||
} catch (e) {
|
||||
alert("返显失败:" + e.message)
|
||||
alert("返显失败:" + e.msg)
|
||||
}
|
||||
})
|
||||
|
||||
@ -346,9 +260,9 @@
|
||||
|
||||
var json = localStorage.getItem("tmp")
|
||||
var def = {
|
||||
manufactor: "sunyard",
|
||||
system: "hsm",
|
||||
customer: "ICBC"
|
||||
manufactor: "SUNYARD@",
|
||||
system: "PAYVER50",
|
||||
customer: "ICBC-ZJ"
|
||||
}
|
||||
try {
|
||||
def = JSON.parse(json)
|
||||
@ -380,28 +294,71 @@
|
||||
customer: $("#customer").val()
|
||||
}
|
||||
|
||||
check(def.manufactor, /\w+/, "厂家标记填写错误")
|
||||
check(def.system, /\w+/, "系统信息填写错误")
|
||||
check(def.customer, /\w+/, "客户信息填写错误")
|
||||
check(def.manufactor, /[\w|@]{8}/, "厂家标记填写错误")
|
||||
check(def.system, /\w{8}/, "系统信息填写错误")
|
||||
check(def.customer, /[\w|\|\-|\-]{7,16}/, "客户信息填写错误")
|
||||
|
||||
try {
|
||||
window.UKey.release(def)
|
||||
|
||||
def.customer += " "
|
||||
def.customer = def.customer.substr(0, 16)
|
||||
|
||||
var info = def.manufactor + def.system + def.customer
|
||||
|
||||
ic.writeText(0, info).then(function () {
|
||||
success("发行成功")
|
||||
}).catch(function (e) {
|
||||
alert("发行失败:" + e.msg)
|
||||
});
|
||||
} catch (e) {
|
||||
alert("发行失败:" + e.message)
|
||||
console.log( e )
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
|
||||
$("#reset").click(function () {
|
||||
alert("暂不开放")
|
||||
|
||||
$("#btn_clear").click(function () {
|
||||
$("#path1").val("");
|
||||
$("#path2").val("");
|
||||
})
|
||||
$("#update1").click(function () {
|
||||
alert("暂不开放")
|
||||
|
||||
$("#btn_read").click(function () {
|
||||
ic.readText(0x20, 1)
|
||||
.then(function (def){
|
||||
$("#path1").val(def.data);
|
||||
return ic.readText(0x30, 16)
|
||||
})
|
||||
.then(function (def){
|
||||
$("#path2").val(def.data);
|
||||
success("读取成功")
|
||||
})
|
||||
.catch(function (e) {
|
||||
alert("读取失败:" + e.msg)
|
||||
})
|
||||
})
|
||||
$("#btn_write").click(function () {
|
||||
var path1 = $("#path1").val();
|
||||
if ( path1 != "31"
|
||||
&& path1 != "32"
|
||||
&& path1 != "33") {
|
||||
alert("IC卡属主填写错误")
|
||||
return
|
||||
}
|
||||
|
||||
var path2 = $("#path2").val();
|
||||
check(path2, /^([A-Fa-f0-9][A-Fa-f0-9]){16}$/g, "特征字串填充错误")
|
||||
|
||||
ic.writeHex(0x20, path1)
|
||||
.then(function (def){
|
||||
return ic.writeHex(0x30, path2)
|
||||
})
|
||||
.then(function (def){
|
||||
success("写入成功")
|
||||
})
|
||||
.catch(function (e) {
|
||||
alert("写入失败:" + e.msg)
|
||||
})
|
||||
$("#update2").click(function () {
|
||||
alert("暂不开放")
|
||||
})
|
||||
|
||||
})
|
||||
|
@ -119,10 +119,11 @@
|
||||
readonly></textarea>
|
||||
|
||||
|
||||
<input id="filepath" style="width: 300px; height: 1.06rem" type="text" value="\root\mana\name"
|
||||
<input id="filepath" style="width: 260px; height: 1.06rem" type="text" value="\root\mana\name"
|
||||
placeholder="文件">
|
||||
<button id="btn_read" style="margin-right: 0.5rem">读</button>
|
||||
<button id="btn_write" style="margin-right: 1rem">写</button>
|
||||
<button id="btn_write" style="margin-right: 0.5rem">写</button>
|
||||
<button id="btn_delete" style="margin-right: 0.5rem">删</button>
|
||||
|
||||
<textarea id="ta_txt" style="display: block; margin: 1rem 0; width: 375px; height: 100px;"
|
||||
></textarea>
|
||||
@ -280,7 +281,6 @@
|
||||
txt = JSON.stringify(txt, null, 4)
|
||||
|
||||
$("#ta_txt").val( txt )
|
||||
debugger
|
||||
success("读取成功")
|
||||
} catch (e) {
|
||||
alert("读取失败:" + e.message)
|
||||
@ -304,6 +304,21 @@
|
||||
}
|
||||
})
|
||||
|
||||
$("#btn_delete").click(function () {
|
||||
// alert("暂不开放")
|
||||
try {
|
||||
var filepath = $("#filepath").val()
|
||||
var idx = filepath.lastIndexOf("\\")
|
||||
var folder = filepath.substr(0, idx)
|
||||
var file = filepath.substr(idx + 1)
|
||||
|
||||
window.UKey.deleteFile(folder, file);
|
||||
success("删除成功")
|
||||
} catch (e) {
|
||||
alert("删除失败:" + e.message)
|
||||
}
|
||||
})
|
||||
|
||||
$("#btn_nameplate_tmp_load").click(function () {
|
||||
var def = {
|
||||
manufactor: "sunyard",
|
||||
|
@ -88,6 +88,14 @@
|
||||
|
||||
}
|
||||
|
||||
function deleteFile(dir, file){
|
||||
if ( ! hDevice ) {
|
||||
throw new Error("设备未登录")
|
||||
}
|
||||
|
||||
FISECKEY.FILE_DeleteFile(hDevice, dir, file);
|
||||
}
|
||||
|
||||
function readFile(dir, file) {
|
||||
if ( ! hDevice ) {
|
||||
throw new Error("设备未登录")
|
||||
@ -274,6 +282,7 @@
|
||||
catRelease : catRelease,
|
||||
readFile: readFile,
|
||||
writeFile : writeFile,
|
||||
deleteFile : deleteFile,
|
||||
login : login,
|
||||
logout : logout,
|
||||
updatePin : updatePin,
|
||||
|
Loading…
Reference in New Issue
Block a user