You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
hk/test.js

32 lines
959 B

2 years ago
eval(getCryptoJS());
2 years ago
const curve = {
curve: CryptoJS.ECDSA.getCurveByName('secp256r1'),
G: null,
n: null,
h: null
};
2 years ago
const appId = '5ddexxxbdf9e4966b387ba58f4b3fdc3';
const deviceId = '2eexxx84b9fc4860b9427feb97a4c142';
const userId = '3426axxxbaa04e1ea9ee01bd998d06d4';
let nonce = 0;
// 生成密钥对
const keyPair = CryptoJS.ECDSA.generateKeyPair(curve);
2 years ago
function sha256(str) {
2 years ago
const hash = CryptoJS.SHA256(str);
return hash.toString(CryptoJS.enc.Hex);
2 years ago
}
2 years ago
function getRandomBytes(len) {
const arr = new Uint8Array(len);
2 years ago
CryptoJS.lib.WordArray.random(len).toArray().forEach((val, idx) => arr[idx] = val);
2 years ago
return Array.from(arr, (dec) => ('0' + dec.toString(16)).substr(-2)).join('');
2 years ago
}
2 years ago
function toHex(buf) {
2 years ago
return Array.prototype.map.call(buf, x => ('00' + x.toString(16)).slice(-2)).join('');
2 years ago
}
2 years ago
function fromHex(hex) {
return new Uint8Array(hex.match(/.{1,2}/g).map(byte => parseInt(byte, 16)));
}
2 years ago
2 years ago
toast('加载完')
setResult(d);