keystore_wdc
Version:
``` npm i keystore_wdc; const KeyStore = require('keystore_wdc'); const ks = new KeyStore(); ``` #### 生成keystore ``` async function create(){ const keystore = await ks.Create("your password"); } ``` * 返回keystore,密码格式不正确返回-1。
53 lines (44 loc) • 1.66 kB
HTML
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<script src="https://requirejs.org/docs/release/2.3.6/minified/require.js">
</script>
<script>
function encodeHex(arr) {
let ret = ''
for (let i = 0; i < arr.length; i++) {
const n = arr[i]
ret += (n > 0x0f ? n.toString(16) : '0' + n.toString(16))
}
return ret
}
function hexToInt(x) {
if (48 <= x && x <= 57) return x - 48;
if (97 <= x && x <= 102) return x - 87;
if (65 <= x && x <= 70) return x - 55;
return 0;
}
function decodeHex(s) {
const ret = new Uint8Array(s.length / 2);
for (let i = 0; i < s.length / 2; i++) {
const h = s.charCodeAt(i * 2);
const l = s.charCodeAt(i * 2 + 1);
ret[i] = (hexToInt(h) << 4) + hexToInt(l);
}
return ret;
}
window.onload = () => {
require(['../argon2b.js'], fn => {
const s1 = '74717a766a333074666a7273656731306f6d393868626966626a763638656e3200000000'
const salt = decodeHex('37343731376137363661333333303734363636613732373336353637333133303666366433393338363836323639363636323661373633363338363536653332')
fn(s1, salt).then(encodeHex).then(console.log)
})
}
</script>
</body>
</html>