From 92e8b6512e00fea0b9076ae085b6be076b3bd95a Mon Sep 17 00:00:00 2001 From: yuanwei Date: Fri, 9 Aug 2024 18:02:11 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0UD=E7=AE=A1=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/ud/ud.js | 33 + src/api/ud/udPlan.js | 41 + src/utils/SoftKey.js | 331 ++++++++ src/utils/Syunew3W.js | 1374 +++++++++++++++++++++++++++++++++ src/views/myLogin2.vue | 244 ++++++ src/views/ud/ud.vue | 725 +++++++++++++++++ src/views/ud/udInfoDialog.vue | 338 ++++++++ src/views/ud/udPlanDialog.vue | 216 ++++++ 8 files changed, 3302 insertions(+) create mode 100644 src/api/ud/ud.js create mode 100644 src/api/ud/udPlan.js create mode 100644 src/utils/SoftKey.js create mode 100644 src/utils/Syunew3W.js create mode 100644 src/views/myLogin2.vue create mode 100644 src/views/ud/ud.vue create mode 100644 src/views/ud/udInfoDialog.vue create mode 100644 src/views/ud/udPlanDialog.vue diff --git a/src/api/ud/ud.js b/src/api/ud/ud.js new file mode 100644 index 0000000..02b6ddb --- /dev/null +++ b/src/api/ud/ud.js @@ -0,0 +1,33 @@ +import axios from "@/utils/request"; + +export function listUd(query) { + return axios({ + url: "/ud/info/list", + method: "get", + params: query + }); +} + + +// 保存 +export function saveUd(data, formName, method = "post") { + let url = + formName !== "edit" + ? "/ud/info/save" + : "/ud/info/edit"; + return axios({ + url: url, + method: method, + data: data + }); +} + +// 删除 +export function deleteUd(data) { + return axios({ + url: "/ud/info/delete", + method: "post", + data: data + }); +} + diff --git a/src/api/ud/udPlan.js b/src/api/ud/udPlan.js new file mode 100644 index 0000000..ccafd8b --- /dev/null +++ b/src/api/ud/udPlan.js @@ -0,0 +1,41 @@ +import axios from "@/utils/request"; + +export function listPlan(query) { + return axios({ + url: "/ud/plan/list", + method: "get", + params: query + }); +} + + +// 保存 +export function savePlan(data, formName, method = "post") { + let url = + formName !== "edit" + ? "/ud/plan/save" + : "/ud/plan/edit"; + return axios({ + url: url, + method: method, + data: data + }); +} + +// 删除 +export function deletePlan(data) { + return axios({ + url: "/ud/plan/delete", + method: "post", + data: data + }); +} + + +export function updateStatusPlan(data) { + return axios({ + url: "/ud/plan/updateStatus", + method: "post", + data: data + }); +} diff --git a/src/utils/SoftKey.js b/src/utils/SoftKey.js new file mode 100644 index 0000000..a4de315 --- /dev/null +++ b/src/utils/SoftKey.js @@ -0,0 +1,331 @@ +// JScript source code +export default class SoftKey +{ + constructor() { + } + + +StrEnc = function(InString, Key) +{ + var n;var m; + var nlen; + + var b=Buffer.from(InString); + var zero_buf = Buffer.from([0]); + b = Buffer.concat([b,zero_buf]); + nlen=b.length; + if( b.length < 8) + { + nlen= 8; + } + + var outb=Buffer.alloc(nlen); + var inb=Buffer.alloc(nlen); + b.copy(inb);//如果少于8,则会补0,这里主要是用于补0 + b.copy(outb); + + + for(n=0;n<=(nlen-8);n=n+8) + { + var tmpoutb = this.sub_EnCode(inb,n,Key); + for(m=0;m<8;m++) + { + outb[m+n]=tmpoutb[m]; + } + } + + return outb.toString('hex'); +} + +StrDec = function( InString, Key)// +{ + var n,m; + var inb=new Buffer(InString, 'hex'); + var outb=Buffer.alloc(inb.length ); + inb.copy(outb); + + for( n = 0; n<=inb.length - 8 ;n=n+ 8) + { + var tmpoutb =this.sub_DeCode(inb,n,Key); + for(m=0;m<8;m++) + { + outb[m+n]=tmpoutb[m]; + } + } + + return outb.toString(); +} + +EnCode = function(inb,Key) +{ + this.sub_EnCode(inb,0,Key); +} + +sub_EnCode = function(inb,pos,Key ) +{ + var cnDelta, y, z, a, b, c, d; + var outb=new Uint8Array(8); + var n, i, nlen; + var sum; + var temp, temp_1; + + var buf = new Array(16); + var temp_string; + + cnDelta = 2654435769; + sum = 0; + + nlen = Key.length ; + i = 0; + for (n = 1; n <= nlen; n = n + 2) + { + temp_string= Key.substring(n-1, n-1+2); + buf[i] = this.HexToInt(temp_string); + i = i + 1; + } + a = 0; b = 0; c = 0; d = 0; + for (n = 0; n <= 3; n++) + { + a = (buf[n] << (n * 8)) | a; + b = (buf[n + 4] << (n * 8)) | b; + c = (buf[n + 4 + 4] << (n * 8)) | c; + d = (buf[n + 4 + 4 + 4] << (n * 8)) | d; + } + + y = 0; + z = 0; + for (n = 0; n <= 3; n++) + { + y = (inb[n + pos] << (n * 8)) | y; + z = (inb[n + 4 + pos]<< (n * 8)) | z; + } + + n = 32; + + while (n > 0) + { + sum = cnDelta + sum; + + temp = (z << 4) & 0xFFFFFFFF; + + temp = (temp + a) & 0xFFFFFFFF; + temp_1 = (z + sum) & 0xFFFFFFFF; + temp = (temp ^ temp_1) & 0xFFFFFFFF; + temp_1 = (z >>>5) & 0xFFFFFFFF; + temp_1 = (temp_1 + b) & 0xFFFFFFFF; + temp = (temp ^ temp_1) & 0xFFFFFFFF; + temp = (temp + y) & 0xFFFFFFFF; + y = temp & 0xFFFFFFFF; + // y += ((z << 4) + a) ^ (z + sum) ^ ((z >> 5) + b); + + temp = (y << 4) & 0xFFFFFFFF; + temp = (temp + c) & 0xFFFFFFFF; + temp_1 = (y + sum) & 0xFFFFFFFF; + temp = (temp ^ temp_1) & 0xFFFFFFFF; + temp_1 = (y >>> 5) & 0xFFFFFFFF; + temp_1 = (temp_1 + d) & 0xFFFFFFFF; + temp = (temp ^ temp_1) & 0xFFFFFFFF; + temp = (z + temp) & 0xFFFFFFFF; + z = temp & 0xFFFFFFFF; + // z += ((y << 4) + c) ^ (y + sum) ^ ((y >> 5) + d); + + n = n - 1; + + } + + for (n = 0; n <= 3; n++) + { + outb[n] = ((y >>> (n * 8)) & 255); + outb[n + 4] = ((z >>> (n * 8)) & 255); + } + return outb; + +} + +DeCode = function() +{ + sub_DeCode(inb,0,Key ); +} + + sub_DeCode = function(inb,pos,Key ) +{ + var cnDelta, y, z, a, b, c, d; + var outb=new Uint8Array(8); + var n, i, nlen; + var sum; + var temp, temp_1; + + var buf = new Array(16); + var temp_string; + + cnDelta = 2654435769; + sum = 3337565984; + + nlen = Key.length ; + i = 0; + for (n = 1; n <= nlen; n = n + 2) + { + temp_string= Key.substring(n-1, n-1+2); + buf[i] = this.HexToInt(temp_string); + i = i + 1; + } + a = 0; b = 0; c = 0; d = 0; + for (n = 0; n <= 3; n++) + { + a = (buf[n] << (n * 8)) | a; + b = (buf[n + 4] << (n * 8)) | b; + c = (buf[n + 4 + 4] << (n * 8)) | c; + d = (buf[n + 4 + 4 + 4] << (n * 8)) | d; + } + + y = 0; + z = 0; + for (n = 0; n <= 3; n++) + { + y = (inb[n + pos] << (n * 8)) | y; + z = (inb[n + 4 + pos]<< (n * 8)) | z; + } + + n = 32; + + while (n > 0) + { + + temp = (y << 4) & 0xFFFFFFFF; + temp = (temp + c) & 0xFFFFFFFF; + temp_1 = (y + sum) & 0xFFFFFFFF; + temp = (temp ^ temp_1) & 0xFFFFFFFF; + temp_1 = (y >>> 5) & 0xFFFFFFFF; + temp_1 = (temp_1 + d) & 0xFFFFFFFF; + temp = (temp ^ temp_1) & 0xFFFFFFFF; + temp = (z - temp) & 0xFFFFFFFF; + z = temp & 0xFFFFFFFF; + // z += ((y << 4) + c) ^ (y + sum) ^ ((y >> 5) + d); + + temp = (z << 4) & 0xFFFFFFFF; + temp = (temp + a) & 0xFFFFFFFF; + temp_1 = (z + sum) & 0xFFFFFFFF; + temp = (temp ^ temp_1) & 0xFFFFFFFF; + temp_1 = (z >>>5) & 0xFFFFFFFF; + temp_1 = (temp_1 + b) & 0xFFFFFFFF; + temp = (temp ^ temp_1) & 0xFFFFFFFF; + temp = ( y -temp) & 0xFFFFFFFF; + y = temp & 0xFFFFFFFF; + // y += ((z << 4) + a) ^ (z + sum) ^ ((z >> 5) + b); + + + + sum = sum-cnDelta; + n = n - 1; + + } + + for (n = 0; n <= 3; n++) + { + outb[n] = ((y >>> (n * 8)) & 255); + outb[n + 4] = ((z >>> (n * 8)) & 255); + } + return outb; + +} + + ///////////////////// +AddZero = function( InKey) +{ + var nlen; + var n; + nlen =InKey.length; + for(n=nlen;n<=7;n++) + { + InKey = "0" + InKey; + } + return InKey; +} + +myconvert = function( HKey, LKey) +{ + HKey = this.AddZero(HKey); + LKey = this.AddZero(LKey); + var out_data=new Uint8Array(8) + var n; + for(n=0;n<=3;n++) + { + out_data[n] = this.HexToInt(HKey.substring( n * 2, n * 2+2)); + } + for(n=0;n<=3;n++) + { + out_data[n + 4] = this.HexToInt(LKey.substring( n * 2, n * 2+2)); + } + return out_data; +} + +////bin2hex & hex2bin + ByteArrayToHexString = function(Inb,len) + { + var outstring= ""; + for (var n = 0 ;n<= len - 1;n++) + { + outstring= outstring+this.myhex(Inb[n]) ; + } + return outstring; + } + +HexStringToByteArray = function(InString) + { + var nlen; + var retutn_len; + var n,i; + var b; + var temp; + nlen = InString.length; + if (nlen < 16) retutn_len = 16; + retutn_len = nlen / 2; + b = new Uint8Array(retutn_len); + i = 0; + for(n=0;n 0; i--) + { + ch = s.substring(i - 1, i-1+1); + n = 0; + for (j = 0; j < 16; j++) + { + if (ch == hexch.substring(j, j+1) ) + { + n = j; + } + } + r += (n * k); + k *= 16; + } + return r; + }; + + +} diff --git a/src/utils/Syunew3W.js b/src/utils/Syunew3W.js new file mode 100644 index 0000000..f90225e --- /dev/null +++ b/src/utils/Syunew3W.js @@ -0,0 +1,1374 @@ + + export default class SoftKey3W +{ + static Socket_UK; + static url; + static LastError + constructor() { + + var isIE11 = navigator.userAgent.indexOf('Trident') > -1 && navigator.userAgent.indexOf("rv:11.0") > -1; + var isEDGE= navigator.userAgent.indexOf("Edge") > -1; + var u = document.URL; + if (u.substring(0, 5) == "https") { + if(isIE11 || isEDGE) + { + if(isIE11)this.url = "wss://127.0.0.1:4006/xxx"; else url = "ws://127.0.0.1:4006/xxx"; + } + else + { + this.url = "ws://localhost:4006/xxx"; + } + } else { + this.url = "ws://127.0.0.1:4006/xxx"; + } + + if (typeof MozWebSocket != "undefined") { + this.Socket_UK = new MozWebSocket(this.url,"usbkey-protocol"); + } else { + this.Socket_UK = new WebSocket(this.url,"usbkey-protocol"); + } + this.Socket_UK.onerror = (event) => { + alert('未能连接服务程序,请确定服务程序是否安装。'); + }; + SoftKey3W.LastError=0 + } + + _FindPort = function (UK,start) + { + var msg = + { + FunName: "FindPort", + start: start + }; + UK.send(JSON.stringify(msg)); + }; + + _FindPort_2 = function (UK,start, in_data , verf_data) + { + var msg = + { + FunName: "FindPort_2", + start: start, + in_data: in_data, + verf_data:verf_data + }; + UK.send(JSON.stringify(msg)); + }; + + _FindPort_3 = function (UK,start,in_data,verf_data) + { + var msg = + { + FunName: "FindPort_3", + start: start, + in_data: in_data, + verf_data:verf_data + }; + UK.send(JSON.stringify(msg)); + }; + + _GetVersion = function (UK,Path) + { + var msg = + { + FunName: "GetVersion", + Path: Path + }; + UK.send(JSON.stringify(msg)); + }; + + _GetVersionEx = function (UK,Path) + { + var msg = + { + FunName: "GetVersionEx", + Path: Path + }; + UK.send(JSON.stringify(msg)); + }; + + _GetID_1 = function (UK,Path) + { + var msg = + { + FunName: "GetID_1", + Path: Path + }; + UK.send(JSON.stringify(msg)); + }; + + _GetID_2 = function (UK,Path) + { + var msg = + { + FunName: "GetID_2", + Path: Path + }; + UK.send(JSON.stringify(msg)); + }; + + + _sRead = function (UK,Path) + { + var msg = + { + FunName: "sRead", + Path: Path + }; + UK.send(JSON.stringify(msg)); + }; + + _sWrite = function (UK,InData, Path) + { + var msg = + { + FunName: "sWrite", + InData: InData, + Path:Path + }; + UK.send(JSON.stringify(msg)); + }; + + _sWrite_2 = function (UK,InData, Path) + { + var msg = + { + FunName: "sWrite_2", + InData: InData, + Path:Path + }; + UK.send(JSON.stringify(msg)); + }; + + _sWrite_2Ex = function (UK,InData,Path) + { + var msg = + { + FunName: "sWrite_2Ex", + InData: InData, + Path:Path + }; + UK.send(JSON.stringify(msg)); + }; + + _sWriteEx = function (UK,InData,Path) + { + var msg = + { + FunName: "sWriteEx", + InData: InData, + Path:Path + }; + UK.send(JSON.stringify(msg)); + }; + + _sWriteEx_New = function (UK,InData,Path) + { + var msg = + { + FunName: "sWriteEx_New", + InData: InData, + Path:Path + }; + UK.send(JSON.stringify(msg)); + }; + + _sWrite_2Ex_New = function (UK,InData,Path) + { + var msg = + { + FunName: "sWrite_2Ex_New", + InData: InData, + Path:Path + }; + UK.send(JSON.stringify(msg)); + }; + + + _YRead= function(Address,HKey,LKey,Path) + { + var msg = + { + FunName: "YRead", + Address:Address, + HKey:HKey, + LKey:LKey, + Path:Path + }; + Socket_UK.send(JSON.stringify(msg)); + }; + + _YWrite= function(InData,Address,HKey,LKey,Path) + { + var msg = + { + FunName: "YWrite", + InData:InData, + Address:Address, + HKey:HKey, + LKey:LKey, + Path:Path + }; + Socket_UK.send(JSON.stringify(msg)); + }; + + + static _SetBuf= function(UK,InData,pos) + { + var msg = + { + FunName: "SetBuf", + InData: InData, + pos:pos + }; + UK.send(JSON.stringify(msg)); + }; + + static _GetBuf= function(UK,pos) + { + var msg = + { + FunName: "GetBuf", + pos: pos + }; + UK.send(JSON.stringify(msg)); + }; + + static _YReadEx= function(UK,Address,len, HKey,LKey,Path) + { + var msg = + { + FunName: "YReadEx", + Address:Address, + len:len, + HKey:HKey, + LKey:LKey, + Path:Path + }; + UK.send(JSON.stringify(msg)); + }; + + static _YWriteEx= function (UK,Address,len,HKey,LKey,Path) + { + var msg = + { + FunName: "YWriteEx", + Address:Address, + len:len, + HKey:HKey, + LKey:LKey, + Path:Path + }; + UK.send(JSON.stringify(msg)); + }; + + _YReadString = function (UK,Address,len,HKey,LKey,Path) + { + var msg = + { + FunName: "YReadString", + Address:Address, + len:len, + HKey:HKey, + LKey:LKey, + Path:Path + }; + UK.send(JSON.stringify(msg)); + }; + + _YWriteString = function (UK,InString,Address,HKey,LKey,Path) + { + var msg = + { + FunName: "YWriteString", + InString:InString, + Address:Address, + HKey:HKey, + LKey:LKey, + Path:Path + }; + UK.send(JSON.stringify(msg)); + }; + + _SetWritePassword = function (UK,W_Hkey,W_Lkey,new_Hkey,new_Lkey,Path) + { + var msg = + { + FunName: "SetWritePassword", + W_Hkey:W_Hkey, + W_Lkey:W_Lkey, + new_Hkey:new_Hkey, + new_Lkey:new_Lkey, + Path:Path + }; + UK.send(JSON.stringify(msg)); + }; + + _SetReadPassword = function (UK,W_Hkey,W_Lkey,new_Hkey,new_Lkey,Path) + { + var msg = + { + FunName: "SetReadPassword", + W_Hkey:W_Hkey, + W_Lkey:W_Lkey, + new_Hkey:new_Hkey, + new_Lkey:new_Lkey, + Path:Path + }; + UK.send(JSON.stringify(msg)); + }; + + + _DecString = function (UK,InString,Key) + { + var msg = + { + FunName: "DecString", + InString:InString, + Key:Key + }; + UK.send(JSON.stringify(msg)); + }; + + _EncString = function (UK,InString,Path) + { + var msg = + { + FunName: "EncString", + InString:InString, + Path:Path + }; + UK.send(JSON.stringify(msg)); + }; + + _EncString_New = function (UK,InString,Path) + { + var msg = + { + FunName: "EncString_New", + InString:InString, + Path:Path + }; + UK.send(JSON.stringify(msg)); + }; + + _Cal = function(UK,Path) + { + var msg = + { + FunName: "Cal", + Path:Path + }; + UK.send(JSON.stringify(msg)); + }; + + _Cal_New = function(UK,Path) + { + var msg = + { + FunName: "Cal_New", + Path:Path + }; + UK.send(JSON.stringify(msg)); + }; + + _GetProduceDate= function(UK,Path) + { + var msg = + { + FunName: "GetProduceDate", + Path:Path + }; + UK.send(JSON.stringify(msg)); + }; + + _SetID= function(UK,Seed,Path) + { + var msg = + { + FunName: "SetID", + Seed:Seed, + Path:Path + }; + UK.send(JSON.stringify(msg)); + }; + + _SetCal_2 = function (UK,Key,Path) + { + var msg = + { + FunName: "SetCal_2", + Key:Key, + Path:Path + }; + UK.send(JSON.stringify(msg)); + }; + + _SetCal_2 = function (UK,Key,Path) + { + var msg = + { + FunName: "SetCal_2", + Key:Key, + Path:Path + }; + UK.send(JSON.stringify(msg)); + }; + + _SetCal_New = function (UK,Key,Path) + { + var msg = + { + FunName: "SetCal_New", + Key:Key, + Path:Path + }; + UK.send(JSON.stringify(msg)); + }; + + static _SetEncBuf= function(UK,InData,pos) + { + var msg = + { + FunName: "SetEncBuf", + InData:InData, + pos: pos + }; + UK.send(JSON.stringify(msg)); + }; + + static _GetEncBuf= function(UK,pos) + { + var msg = + { + FunName: "GetEncBuf", + pos: pos + }; + UK.send(JSON.stringify(msg)); + }; + + + _ReSet = function (UK,Path) + { + var msg = + { + FunName: "ReSet", + Path:Path + }; + UK.send(JSON.stringify(msg)); + }; + + _MacAddr = function (UK) + { + var msg = + { + FunName: "MacAddr" + }; + UK.send(JSON.stringify(msg)); + }; + + + _GetChipID = function (UK,Path) + { + var msg = + { + FunName: "GetChipID", + Path:Path + }; + UK.send(JSON.stringify(msg)); + }; + + static _StarGenKeyPair= function(UK,Path) + { + var msg = + { + FunName: "StarGenKeyPair", + Path:Path + }; + UK.send(JSON.stringify(msg)); + }; + + static _GenPubKeyY= function(UK) + { + var msg = + { + FunName: "GenPubKeyY" + }; + UK.send(JSON.stringify(msg)); + }; + + static _GenPubKeyX= function(UK) + { + var msg = + { + FunName: "GenPubKeyX" + }; + UK.send(JSON.stringify(msg)); + }; + + static _GenPriKey= function(UK) + { + var msg = + { + FunName: "GenPriKey" + }; + UK.send(JSON.stringify(msg)); + }; + + _GetPubKeyY = function (UK,Path) + { + var msg = + { + FunName: "GetPubKeyY", + Path:Path + }; + UK.send(JSON.stringify(msg)); + }; + + _GetPubKeyX = function (UK,Path) + { + var msg = + { + FunName: "GetPubKeyX", + Path:Path + }; + UK.send(JSON.stringify(msg)); + }; + + _GetSm2UserName = function (UK,Path) + { + var msg = + { + FunName: "GetSm2UserName", + Path:Path + }; + UK.send(JSON.stringify(msg)); + }; + + _Set_SM2_KeyPair = function (UK,PriKey,PubKeyX,PubKeyY,sm2UserName,Path ) + { + var msg = + { + FunName: "Set_SM2_KeyPair", + PriKey:PriKey, + PubKeyX:PubKeyX, + PubKeyY:PubKeyY, + sm2UserName:sm2UserName, + Path:Path + }; + UK.send(JSON.stringify(msg)); + }; + + _YtSign = function (UK,SignMsg,Pin,Path) + { + var msg = + { + FunName: "YtSign", + SignMsg:SignMsg, + Pin:Pin, + Path:Path + }; + UK.send(JSON.stringify(msg)); + }; + + _YtSign_2 = function (UK,SignMsg,Pin,Path) + { + var msg = + { + FunName: "YtSign_2", + SignMsg:SignMsg, + Pin:Pin, + Path:Path + }; + UK.send(JSON.stringify(msg)); + }; + + _YtVerfiy = function (UK,id,SignMsg,PubKeyX, PubKeyY,VerfiySign,Path) + { + var msg = + { + FunName: "YtVerfiy", + id:id, + SignMsg:SignMsg, + PubKeyX:PubKeyX, + PubKeyY:PubKeyY, + VerfiySign:VerfiySign, + Path:Path + }; + UK.send(JSON.stringify(msg)); + }; + + _SM2_DecString = function (UK,InString,Pin,Path) + { + var msg = + { + FunName: "SM2_DecString", + InString:InString, + Pin:Pin, + Path:Path + }; + UK.send(JSON.stringify(msg)); + }; + + _SM2_EncString = function (UK,InString,Path) + { + var msg = + { + FunName: "SM2_EncString", + InString:InString, + Path:Path + }; + UK.send(JSON.stringify(msg)); + }; + + _YtSetPin = function (UK,OldPin,NewPin,Path) + { + var msg = + { + FunName: "YtSetPin", + OldPin:OldPin, + NewPin:NewPin, + Path:Path + }; + UK.send(JSON.stringify(msg)); + }; + + _FindU = function (UK,start) + { + var msg = + { + FunName: "FindU", + start: start + }; + UK.send(JSON.stringify(msg)); + }; + + _FindU_2 = function (UK,start,in_data,verf_data) + { + var msg = + { + FunName: "FindU_2", + start: start, + in_data: in_data, + verf_data:verf_data + }; + UK.send(JSON.stringify(msg)); + }; + + _FindU_3 = function (UK,start,in_data,verf_data) + { + var msg = + { + FunName: "FindU_3", + start: start, + in_data: in_data, + verf_data:verf_data + }; + UK.send(JSON.stringify(msg)); + }; + + _IsUReadOnly = function (UK,Path) + { + var msg = + { + FunName: "IsUReadOnly", + Path:Path + }; + UK.send(JSON.stringify(msg)); + }; + + _SetUReadOnly = function (UK,Path) + { + var msg = + { + FunName: "SetUReadOnly", + Path:Path + }; + UK.send(JSON.stringify(msg)); + }; + + _SetHidOnly = function (UK,IsHidOnly,Path) + { + var msg = + { + FunName: "SetHidOnly", + IsHidOnly:IsHidOnly, + Path:Path + }; + UK.send(JSON.stringify(msg)); + }; + + static ResetOrder= function(UK) + { + var msg = + { + FunName: "ResetOrder" + }; + UK.send(JSON.stringify(msg)); + } + + ContinueOrder = function (UK) + { + var msg = + { + FunName: "ContinueOrder" + }; + UK.send(JSON.stringify(msg)); + } + + + _ComputerName= function(UK) + { + var msg = + { + FunName: "ComputerName" + }; + UK.send(JSON.stringify(msg)); + }; + + + + SendCmdAndWait = function(IsReturnErr,fun,param1,param2,param3,param4,param5,param6,param7,param8,param9,param10) +{ + var UK; + + return new Promise((resolve, reject) => { + + if (typeof MozWebSocket != "undefined") { + UK = new MozWebSocket(this.url,"usbkey-protocol"); + } else { + UK = new WebSocket(this.url,"usbkey-protocol"); + } + + try + { + UK.onopen = function() { + SoftKey3W.ResetOrder(UK);// + } + + UK.onmessage =function got_packet(Msg) + { + var UK_Data = JSON.parse(Msg.data); + var return_value; + if(UK_Data.type!="Process")return ;// + switch(UK_Data.order) + { + case 0: + { + fun(UK,param1,param2,param3,param4,param5,param6,param7,param8,param9,param10); + } + break; //!!!!! + case 1: + { + SoftKey3W.LastError=UK_Data.LastError; + return_value=UK_Data.return_value; + if( SoftKey3W.LastError!=0){ + if(IsReturnErr)return_value=SoftKey3W.LastError; + } + // + UK.close(); + + resolve(return_value); + } + break; + } + } + UK.onclose = function(){ + + } + UK.onerror = (event) => { + alert('未能连接服务程序,请确定服务程序是否安装。'); + }; + } + catch(e) + { + alert(e.name + ": " + e.message); + resolve(false); + } + }) +} + + GetLastError = function() + { + return SoftKey3W.LastError; + } + + FindPort = function(start) + { + return this.SendCmdAndWait(false,this._FindPort,start); + } + + FindPort_2= function( start,in_data, verf_data ) + { + return this.SendCmdAndWait(false,this._FindPort_2,start,in_data, verf_data); + }; + + GetVersionEx= function(KeyPath) + { + return this.SendCmdAndWait(false,this._GetVersionEx,KeyPath); + }; + + GetVersion= function(KeyPath) + { + return this.SendCmdAndWait(false,this._GetVersion,KeyPath); + }; + + + + GetID_1= function(KeyPath) + { + return this.SendCmdAndWait(false,this._GetID_1,KeyPath); + } + + GetID_2= function(KeyPath) + { + return this.SendCmdAndWait(false,this._GetID_2,KeyPath); + + } + + GetChipID= function(KeyPath) + { + return this.SendCmdAndWait(false,this._GetChipID,KeyPath); + + }; + + SetWritePassword= function( W_HKey, W_LKey, new_HKey, new_LKey,KeyPath) + { + return this.SendCmdAndWait(true,this._SetWritePassword, W_HKey, W_LKey, new_HKey, new_LKey,KeyPath); + } + + SetReadPassword= function( W_HKey, W_LKey, new_HKey, new_LKey,KeyPath) + { + return this.SendCmdAndWait(true,this._SetReadPassword,W_HKey, W_LKey, new_HKey, new_LKey,KeyPath); + } + + + SetCal_2= function( Key,KeyPath) + { + return this.SendCmdAndWait(true,this._SetCal_2,Key,KeyPath); + } + + SetCal_New= function(Key,KeyPath) + { + return this.SendCmdAndWait(true,this._SetCal_New,Key,KeyPath); + } + + + EncString= function( InString,KeyPath) + { + return this.SendCmdAndWait(false,this._EncString,InString,KeyPath); + } + + EncString_New= function( InString,KeyPath) + { + return this.SendCmdAndWait(false,this._EncString_New, InString,KeyPath); + } + + + + Cal= function(Inbuf,KeyPath) + { + return SubCal(_Cal,Inbuf,KeyPath); + } + + Cal_New= function(Inbuf,KeyPath) + { + return SubCal(_Cal_New,Inbuf,KeyPath) + } + + + + sWriteEx= function( in_data ,KeyPath) + { + return this.SendCmdAndWait(false,this._sWriteEx,in_data ,KeyPath); + } + + sWrite_2Ex= function( in_data ,KeyPath) + { + return this.SendCmdAndWait(false,this._sWrite_2Ex,in_data ,KeyPath); + } + + sWriteEx_New= function( in_data ,KeyPath) + { + return this.SendCmdAndWait(false,this._sWriteEx_New,in_data ,KeyPath); + } + + sWrite_2Ex_New= function( in_data ,KeyPath) + { + return this.SendCmdAndWait(false,this._sWrite_2Ex_New,in_data ,KeyPath); + } + + sWrite= function( in_data ,KeyPath) + { + return this.SendCmdAndWait(true,this._sWrite,in_data ,KeyPath); + } + + sWrite_2= function( in_data ,KeyPath) + { + return this.SendCmdAndWait(true,this._sWrite_2,in_data ,KeyPath); + } + + sRead= function(KeyPath) + { + return this.SendCmdAndWait(false,this._sRead,KeyPath); + } + + + YWriteEx = function(indata, address, nlen, HKey, LKey,KeyPath) + { + var UK; + + return new Promise((resolve, reject) => { + + if (typeof MozWebSocket != "undefined") { + UK = new MozWebSocket(this.url,"usbkey-protocol"); + } else { + UK = new WebSocket(this.url,"usbkey-protocol"); + } + + try + { + var i=0,order; + UK.onopen = function() { + SoftKey3W.ResetOrder(UK);// + + } + + UK.onmessage =function got_packet(Msg) + { + var UK_Data = JSON.parse(Msg.data); + var return_value; + if(UK_Data.type!="Process")return ;// + if(UK_Data.order { + alert('未能连接服务程序,请确定服务程序是否安装。'); + }; + } + catch(e) + { + alert(e.name + ": " + e.message); + resolve(false); + } + }) +} + + + YWriteString= function(InString,Address , HKey, LKey,KeyPath) + { + return this.SendCmdAndWait(true,this._YWriteString,InString,Address , HKey, LKey,KeyPath); + } + + YReadEx= function(address, nlen, HKey, LKey,KeyPath ) + { + var outb = new Uint8Array(nlen); + var UK; + return new Promise((resolve, reject) => { + + if (typeof MozWebSocket != "undefined") { + UK = new MozWebSocket(this.url,"usbkey-protocol"); + } else { + UK = new WebSocket(this.url,"usbkey-protocol"); + } + + try + { + var i,order; + UK.onopen = function() { + SoftKey3W.ResetOrder(UK);// + + } + + UK.onmessage =function got_packet(Msg) + { + var UK_Data = JSON.parse(Msg.data); + var return_value; + if(UK_Data.type!="Process")return ;// + if(UK_Data.order<2) + { + + switch(UK_Data.order) + { + case 0: + { + SoftKey3W._YReadEx(UK,address, nlen, HKey, LKey,KeyPath); + } + break; //!!!!! + case 1: + { + SoftKey3W.LastError=UK_Data.LastError; + if( SoftKey3W.LastError!=0){ UK.close();resolve(outb);return ; } + + i=0; + SoftKey3W._GetBuf(UK,i);// + } + break; + } + } + else{ + SoftKey3W.LastError=UK_Data.LastError; + if( SoftKey3W.LastError!=0){ UK.close();resolve(outb);return ; } + outb[i]=UK_Data.return_value; + i++; + if( UK_Data.LastError!=0 || i>=nlen) + { + UK.close();resolve(outb);return ; + } + SoftKey3W._GetBuf(UK,i);// + + } + } + UK.onclose = function(){ + + } + UK.onerror = (event) => { + alert('未能连接服务程序,请确定服务程序是否安装。'); + }; + } + catch(e) + { + alert(e.name + ": " + e.message); + resolve(false); + } + }) + return outb; + } + + YReadString= function( Address, nlen, HKey, LKey,KeyPath) + { + return this.SendCmdAndWait(false,this._YReadString,Address, nlen, HKey, LKey,KeyPath); + } + + + YRead= function(Address,HKey,LKey,Path) + { + return this.SendCmdAndWait(false,this._YRead,Address,HKey,LKey,Path); + }; + + YWrite= function(InData,Address,HKey,LKey,Path) + { + return this.SendCmdAndWait(true,this._YWrite,InData,Address,HKey,LKey,Path) + }; + + + ReSet= function( KeyPath ) + { + return this.SendCmdAndWait(true,this._ReSet,KeyPath); + } + + + SetCal= function( HKey, LKey, new_HKey, new_LKey, KeyPath) + { + return this.SendCmdAndWait(true,this._SetCal,HKey, LKey, new_HKey, new_LKey,KeyPath); + } + + + + SetID= function( Seed, KeyPath) + { + return this.SendCmdAndWait(true,this._SetID, Seed,KeyPath); + } + + GetProduceDate= function( KeyPath) + { + return this.SendCmdAndWait(false,this._GetProduceDate,KeyPath); + } + + SetHidOnly= function( IsHidOnly, KeyPath) + { + return this.SendCmdAndWait(true,this._SetHidOnly, IsHidOnly,KeyPath); + } + + + SetUReadOnly= function(KeyPath) + { + return this.SendCmdAndWait(true,this._SetUReadOnly,KeyPath); + } + + + StarGenKeyPair = function(KeyPath) + { + var KeyPairInfo={ + GenPriKey:"", + GenPubKeyX:"", + GenPubKeyY:"", + } + var UK; + + return new Promise((resolve, reject) => { + + if (typeof MozWebSocket != "undefined") { + UK = new MozWebSocket(this.url,"usbkey-protocol"); + } else { + UK = new WebSocket(this.url,"usbkey-protocol"); + } + try + { + UK.onopen = function() { + SoftKey3W.ResetOrder(UK);// + } + + UK.onmessage =function got_packet(Msg) + { + var UK_Data = JSON.parse(Msg.data); + var return_value; + if(UK_Data.type!="Process")return ;// + switch(UK_Data.order) + { + case 0: + { + SoftKey3W._StarGenKeyPair(UK,KeyPath); + } + break; // + case 1: + { + SoftKey3W.LastError=UK_Data.LastError; + if( SoftKey3W.LastError!=0){UK.close(); resolve(KeyPairInfo);return ;} + SoftKey3W._GenPriKey(UK); + } + break; + case 2: + { + SoftKey3W.LastError=UK_Data.LastError; + if( SoftKey3W.LastError!=0){UK.close(); resolve(KeyPairInfo);return ;} + KeyPairInfo.GenPriKey=UK_Data.return_value; + SoftKey3W._GenPubKeyX(UK); + } + break; + case 3: + { + SoftKey3W.LastError=UK_Data.LastError; + if( SoftKey3W.LastError!=0){UK.close(); resolve(KeyPairInfo);return ;} + KeyPairInfo.GenPubKeyX=UK_Data.return_value; + SoftKey3W._GenPubKeyY(UK); + } + break; + case 4: + { + SoftKey3W.LastError=UK_Data.LastError; + if( SoftKey3W.LastError!=0){UK.close(); resolve(KeyPairInfo);return ;} + KeyPairInfo.GenPubKeyY=UK_Data.return_value; + + UK.close(); resolve(KeyPairInfo);return ; + } + break; + } + } + UK.onclose = function(){ + + } + UK.onerror = (event) => { + alert('未能连接服务程序,请确定服务程序是否安装。'); + }; + } + catch(e) + { + alert(e.name + ": " + e.message); + resolve(false); + } + }) + } + + + + Set_SM2_KeyPair= function(PriKey, PubKeyX, PubKeyY, SM2_UserName, KeyPath) + { + return this.SendCmdAndWait(true,this._Set_SM2_KeyPair,PriKey, PubKeyX, PubKeyY, SM2_UserName,KeyPath); + } + + Get_SM2_PubKey= function(KeyPath) + { + return this.SendCmdAndWait(false,this._Get_SM2_PubKey,KeyPath); + } + + GetPubKeyX= function(KeyPath) + { + return this.SendCmdAndWait(false,this._GetPubKeyX,KeyPath); + } + + GetPubKeyY= function(KeyPath) + { + return this.SendCmdAndWait(false,this._GetPubKeyY,KeyPath); + } + + GetSm2UserName= function(KeyPath) + { + return this.SendCmdAndWait(false,this._GetSm2UserName,KeyPath); + } + + SM2_EncBuf= function( InBuf, inlen, KeyPath) + { + return this.SendCmdAndWait(true,this._SM2_EncBuf, InBuf, inlen,KeyPath); + } + + SM2_DecBuf= function( InBuf, inlen, pin, KeyPath) + { + return this.SendCmdAndWait(true,this._SM2_DecBuf,InBuf, inlen, pin, KeyPath); + } + + SM2_EncString= function(InString, KeyPath) + { + return this.SendCmdAndWait(false,this._SM2_EncString,InString, KeyPath); + } + + SM2_DecString= function(InString, pin, KeyPath) + { + return this.SendCmdAndWait(false,this._SM2_DecString,InString, pin,KeyPath); + } + + YtSetPin= function(old_pin, new_pin, KeyPath) + { + return this.SendCmdAndWait(true,this._YtSetPin,old_pin, new_pin, KeyPath); + } + + + YtSign= function(msg, pin, KeyPath) + { + return this.SendCmdAndWait(false,this._YtSign,msg, pin, KeyPath); + } + + YtSign_2= function(msg, pin, KeyPath) + { + return this.SendCmdAndWait(false,this._YtSign_2,msg, pin, KeyPath); + } + + MacAddr= function() + { + return this.SendCmdAndWait(false,this._MacAddr); + } + + ComputerName= function() + { + return this.SendCmdAndWait(false,this._ComputerName); + }; + + SubCal = function(Fun,Inbuf,KeyPath) + { + var UK;var outb = new Uint8Array(8); + return new Promise((resolve, reject) => { + + if (typeof MozWebSocket != "undefined") { + UK = new MozWebSocket(this.url,"usbkey-protocol"); + } else { + UK = new WebSocket(this.url,"usbkey-protocol"); + } + + try + { + var i=0,order;var bIsEnc=true; + UK.onopen = function() { + SoftKey3W.ResetOrder(UK);// + + } + + UK.onmessage =function got_packet(Msg) + { + var UK_Data = JSON.parse(Msg.data); + var return_value; + if(UK_Data.type!="Process")return ;// + if(bIsEnc) + { + if(UK_Data.order<8) + { + SoftKey3W._SetEncBuf(UK,Inbuf[UK_Data.order],UK_Data.order); + return; + } + else{ + order=UK_Data.order-8; + } + + switch(order) + { + case 0: + { + SoftKey3W.LastError=UK_Data.LastError; + if( SoftKey3W.LastError!=0){UK.close(); resolve(outb);return ;} + Fun(UK, KeyPath); + } + break; // + case 1: + { + SoftKey3W.LastError=UK_Data.LastError; + return_value=UK_Data.return_value; + if( SoftKey3W.LastError!=0){UK.close(); resolve(outb);return ;} + bIsEnc=false;i=0; + SoftKey3W.ResetOrder(UK); + + } + break; + } + } + else{ + SoftKey3W.LastError=UK_Data.LastError; + if( SoftKey3W.LastError!=0){ + UK.close(); + resolve(outb);return ; + } + if(UK_Data.order<8) + { + if(UK_Data.order>0) + { + outb[i-1]=UK_Data.return_value; + } + SoftKey3W._GetEncBuf(UK,i);// + i++; + } + else{ + outb[i-1]=UK_Data.return_value; + UK.close(); + resolve(outb);return ; + } + } + } + UK.onclose = function(){ + + } + UK.onerror = (event) => { + alert('未能连接服务程序,请确定服务程序是否安装。'); + }; + } + catch(e) + { + alert(e.name + ": " + e.message); + resolve(false); + } + }) +} + + +} + diff --git a/src/views/myLogin2.vue b/src/views/myLogin2.vue new file mode 100644 index 0000000..5d93a59 --- /dev/null +++ b/src/views/myLogin2.vue @@ -0,0 +1,244 @@ + + + + + + diff --git a/src/views/ud/ud.vue b/src/views/ud/ud.vue new file mode 100644 index 0000000..7d4020d --- /dev/null +++ b/src/views/ud/ud.vue @@ -0,0 +1,725 @@ + + + + + + + diff --git a/src/views/ud/udInfoDialog.vue b/src/views/ud/udInfoDialog.vue new file mode 100644 index 0000000..30b388c --- /dev/null +++ b/src/views/ud/udInfoDialog.vue @@ -0,0 +1,338 @@ + + + + + diff --git a/src/views/ud/udPlanDialog.vue b/src/views/ud/udPlanDialog.vue new file mode 100644 index 0000000..3e38366 --- /dev/null +++ b/src/views/ud/udPlanDialog.vue @@ -0,0 +1,216 @@ + + + + +