This commit is contained in:
cheney 2023-01-05 17:39:59 +08:00
parent 24f6019d1b
commit 852c240113
9 changed files with 665 additions and 275 deletions

226
swa/ic/active.ic.min.js vendored Normal file
View 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

Binary file not shown.

View File

@ -143,26 +143,26 @@
<div class="line"> <div class="line">
<span>IC卡属主 (20h+1)</span> <span>IC卡属主 (20h+1)</span>
<input id="path" style="width: 300px; height: 1.06rem" type="text" value="\root\mana" <input id="path1" style="width: 300px; height: 1.06rem" type="text" value="" maxlength="2"
placeholder="文件目录"> placeholder="31/32/33">
</div> </div>
<div class="line"> <div class="line">
<span>特征字串 (30h+16)</span> <span>特征字串 (30h+16)</span>
<input id="path" style="width: 300px; height: 1.06rem" type="text" value="\root\mana" <input id="path2" style="width: 300px; height: 1.06rem" type="text" maxlength="32" value=""
placeholder="文件目录"> placeholder="特征字符串">
</div> </div>
<div class="line"> <div class="line">
<span>主密钥分量 (40h+5)</span> <span>主密钥分量 (40h+5)</span>
<input id="path" style="width: 300px; height: 1.06rem" type="text" value="\root\mana" <input id="path3" style="width: 300px; height: 1.06rem" type="text" value=""
placeholder="文件目录"> placeholder="保留">
</div> </div>
<div class="line"> <div class="line">
<span>LMK0 (50h+16)</span> <span>LMK0 (50h+16)</span>
<input id="path" style="width: 300px; height: 1.06rem" type="text" value="\root\mana" <input id="path4" style="width: 300px; height: 1.06rem" type="text" value=""
placeholder="文件目录"> placeholder="保留">
</div> </div>
<div class="line"> <div class="line">
@ -172,8 +172,9 @@
</div> </div>
<button>读取所有</button> <button id="btn_read">读取所有</button>
<button>写入所有</button> <button id="btn_write">写入所有</button>
<button id="btn_clear">清空</button>
</div> </div>
@ -181,7 +182,7 @@
<ul> <ul>
<li> <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>【2022年12月22日】</p>
<p>第一个发行版本</p> <p>第一个发行版本</p>
</li> </li>
@ -199,8 +200,8 @@
<!-- UKey 支持, 共 3 个 js--> <!-- UKey 支持, 共 3 个 js-->
<!-- jquery --> <!-- jquery -->
<script type="text/javascript" src="./jquery.min.js"></script> <script type="text/javascript" src="./jquery.min.js"></script>
<script type="text/javascript" src="./fiseckey.js"></script> <script type="text/javascript" src="./active.ic.min.js"></script>
<script type="text/javascript" src="./ukey.js"></script>
<!-- 演示程序 --> <!-- 演示程序 -->
@ -209,85 +210,9 @@
<script type="application/javascript" src="tools.js"></script> <script type="application/javascript" src="tools.js"></script>
<script type="application/javascript"> <script type="application/javascript">
$(function () { $(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 () { $("#btn_nameplate_clear").click(function () {
$("#manufactor").val(""); $("#manufactor").val("");
@ -295,25 +220,11 @@
$("#customer").val(""); $("#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 () { $("#btn_nameplate_tmp_load").click(function () {
var def = { var def = {
manufactor: "sunyard", manufactor: "SUNYARD@",
system: "hsm", system: "PAYVER50",
customer: "ICBC" customer: "ICBCZJ"
} }
$("#manufactor").val(def.manufactor); $("#manufactor").val(def.manufactor);
$("#system").val(def.system); $("#system").val(def.system);
@ -323,20 +234,23 @@
$("#btn_nameplate_read").click(function () { $("#btn_nameplate_read").click(function () {
try { try {
var txt = window.UKey.catRelease();
var def = Object.assign({
manufactor: "",
system: "",
customer: ""
}, txt)
$("#manufactor").val(def.manufactor); ic.readText(0, 32)
$("#system").val(def.system);
$("#customer").val(def.customer); .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)
})
success("返显成功")
} catch (e) { } catch (e) {
alert("返显失败:" + e.message) alert("返显失败:" + e.msg)
} }
}) })
@ -346,9 +260,9 @@
var json = localStorage.getItem("tmp") var json = localStorage.getItem("tmp")
var def = { var def = {
manufactor: "sunyard", manufactor: "SUNYARD@",
system: "hsm", system: "PAYVER50",
customer: "ICBC" customer: "ICBCZJ"
} }
try { try {
def = JSON.parse(json) def = JSON.parse(json)
@ -380,28 +294,71 @@
customer: $("#customer").val() customer: $("#customer").val()
} }
check(def.manufactor, /\w+/, "厂家标记填写错误") check(def.manufactor, /[\w|@]{8}/, "厂家标记填写错误")
check(def.system, /\w+/, "系统信息填写错误") check(def.system, /\w{8}/, "系统信息填写错误")
check(def.customer, /\w+/, "客户信息填写错误") check(def.customer, /[\w|\|\|\-]{7,16}/, "客户信息填写错误")
try { try {
window.UKey.release(def)
success("发行成功") 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) { } 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)
})
}) })
$("#update2").click(function () { $("#btn_write").click(function () {
alert("暂不开放") 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)
})
}) })
}) })

View File

@ -119,11 +119,11 @@
readonly></textarea> 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="文件"> placeholder="文件">
<button id="btn_read" style="margin-right: 0.5rem"></button> <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: 1rem"></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 id="ta_txt" style="display: block; margin: 1rem 0; width: 375px; height: 100px;"
></textarea> ></textarea>
@ -297,7 +297,7 @@
var txt = $("#ta_txt").val(); var txt = $("#ta_txt").val();
window.UKey.de(folder, file, txt); window.UKey.writeFile(folder, file, txt);
success("写入成功") success("写入成功")
} catch (e) { } catch (e) {
alert("写入失败:" + e.message) alert("写入失败:" + e.message)

226
www/swa/ic/active.ic.min.js vendored Normal file
View 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;
}
}

Binary file not shown.

View File

@ -143,26 +143,26 @@
<div class="line"> <div class="line">
<span>IC卡属主 (20h+1)</span> <span>IC卡属主 (20h+1)</span>
<input id="path" style="width: 300px; height: 1.06rem" type="text" value="\root\mana" <input id="path1" style="width: 300px; height: 1.06rem" type="text" value="" maxlength="2"
placeholder="文件目录"> placeholder="31/32/33">
</div> </div>
<div class="line"> <div class="line">
<span>特征字串 (30h+16)</span> <span>特征字串 (30h+16)</span>
<input id="path" style="width: 300px; height: 1.06rem" type="text" value="\root\mana" <input id="path2" style="width: 300px; height: 1.06rem" type="text" maxlength="32" value=""
placeholder="文件目录"> placeholder="特征字符串">
</div> </div>
<div class="line"> <div class="line">
<span>主密钥分量 (40h+5)</span> <span>主密钥分量 (40h+5)</span>
<input id="path" style="width: 300px; height: 1.06rem" type="text" value="\root\mana" <input id="path3" style="width: 300px; height: 1.06rem" type="text" value=""
placeholder="文件目录"> placeholder="保留">
</div> </div>
<div class="line"> <div class="line">
<span>LMK0 (50h+16)</span> <span>LMK0 (50h+16)</span>
<input id="path" style="width: 300px; height: 1.06rem" type="text" value="\root\mana" <input id="path4" style="width: 300px; height: 1.06rem" type="text" value=""
placeholder="文件目录"> placeholder="保留">
</div> </div>
<div class="line"> <div class="line">
@ -172,8 +172,9 @@
</div> </div>
<button>读取所有</button> <button id="btn_read">读取所有</button>
<button>写入所有</button> <button id="btn_write">写入所有</button>
<button id="btn_clear">清空</button>
</div> </div>
@ -181,7 +182,7 @@
<ul> <ul>
<li> <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>【2022年12月22日】</p>
<p>第一个发行版本</p> <p>第一个发行版本</p>
</li> </li>
@ -199,8 +200,8 @@
<!-- UKey 支持, 共 3 个 js--> <!-- UKey 支持, 共 3 个 js-->
<!-- jquery --> <!-- jquery -->
<script type="text/javascript" src="./jquery.min.js"></script> <script type="text/javascript" src="./jquery.min.js"></script>
<script type="text/javascript" src="./fiseckey.js"></script> <script type="text/javascript" src="./active.ic.min.js"></script>
<script type="text/javascript" src="./ukey.js"></script>
<!-- 演示程序 --> <!-- 演示程序 -->
@ -209,85 +210,9 @@
<script type="application/javascript" src="tools.js"></script> <script type="application/javascript" src="tools.js"></script>
<script type="application/javascript"> <script type="application/javascript">
$(function () { $(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 () { $("#btn_nameplate_clear").click(function () {
$("#manufactor").val(""); $("#manufactor").val("");
@ -295,25 +220,11 @@
$("#customer").val(""); $("#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 () { $("#btn_nameplate_tmp_load").click(function () {
var def = { var def = {
manufactor: "sunyard", manufactor: "SUNYARD@",
system: "hsm", system: "PAYVER50",
customer: "ICBC" customer: "ICBCZJ"
} }
$("#manufactor").val(def.manufactor); $("#manufactor").val(def.manufactor);
$("#system").val(def.system); $("#system").val(def.system);
@ -323,20 +234,23 @@
$("#btn_nameplate_read").click(function () { $("#btn_nameplate_read").click(function () {
try { try {
var txt = window.UKey.catRelease();
var def = Object.assign({
manufactor: "",
system: "",
customer: ""
}, txt)
$("#manufactor").val(def.manufactor); ic.readText(0, 32)
$("#system").val(def.system);
$("#customer").val(def.customer); .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)
})
success("返显成功")
} catch (e) { } catch (e) {
alert("返显失败:" + e.message) alert("返显失败:" + e.msg)
} }
}) })
@ -346,9 +260,9 @@
var json = localStorage.getItem("tmp") var json = localStorage.getItem("tmp")
var def = { var def = {
manufactor: "sunyard", manufactor: "SUNYARD@",
system: "hsm", system: "PAYVER50",
customer: "ICBC" customer: "ICBCZJ"
} }
try { try {
def = JSON.parse(json) def = JSON.parse(json)
@ -380,28 +294,71 @@
customer: $("#customer").val() customer: $("#customer").val()
} }
check(def.manufactor, /\w+/, "厂家标记填写错误") check(def.manufactor, /[\w|@]{8}/, "厂家标记填写错误")
check(def.system, /\w+/, "系统信息填写错误") check(def.system, /\w{8}/, "系统信息填写错误")
check(def.customer, /\w+/, "客户信息填写错误") check(def.customer, /[\w|\|\|\-]{7,16}/, "客户信息填写错误")
try { try {
window.UKey.release(def)
success("发行成功") 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) { } 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)
})
}) })
$("#update2").click(function () { $("#btn_write").click(function () {
alert("暂不开放") 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)
})
}) })
}) })

View File

@ -119,10 +119,11 @@
readonly></textarea> 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="文件"> placeholder="文件">
<button id="btn_read" style="margin-right: 0.5rem"></button> <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 id="ta_txt" style="display: block; margin: 1rem 0; width: 375px; height: 100px;"
></textarea> ></textarea>
@ -280,7 +281,6 @@
txt = JSON.stringify(txt, null, 4) txt = JSON.stringify(txt, null, 4)
$("#ta_txt").val( txt ) $("#ta_txt").val( txt )
debugger
success("读取成功") success("读取成功")
} catch (e) { } catch (e) {
alert("读取失败:" + e.message) 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 () { $("#btn_nameplate_tmp_load").click(function () {
var def = { var def = {
manufactor: "sunyard", manufactor: "sunyard",

View File

@ -88,6 +88,14 @@
} }
function deleteFile(dir, file){
if ( ! hDevice ) {
throw new Error("设备未登录")
}
FISECKEY.FILE_DeleteFile(hDevice, dir, file);
}
function readFile(dir, file) { function readFile(dir, file) {
if ( ! hDevice ) { if ( ! hDevice ) {
throw new Error("设备未登录") throw new Error("设备未登录")
@ -274,6 +282,7 @@
catRelease : catRelease, catRelease : catRelease,
readFile: readFile, readFile: readFile,
writeFile : writeFile, writeFile : writeFile,
deleteFile : deleteFile,
login : login, login : login,
logout : logout, logout : logout,
updatePin : updatePin, updatePin : updatePin,