1import { hex2patp } from 'urbit-ob';
3import jssha256 from 'js-sha256';
6 const hashed = jssha256.sha256.array(buf);
7 return Buffer.from(hashed);
10function hexToArrayBuffer(hex) {
11 return Buffer.from(hex, 'hex').reverse();
14function buf2hex(buf) {
15 return Buffer.from(buf)
20function shas(buf, salt) {
21 return shax(xor(salt, shax(buf)));
25 const length = Math.max(a.byteLength, b.byteLength);
26 const result = new Uint8Array(length);
27 for (let i = 0; i < length; i++) {
28 result[i] = a[i] ^ b[i];
33function shaf(buf, salt) {
34 const result = shas(buf, salt);
35 const halfway = result.length / 2;
36 const front = result.slice(0, halfway);
37 const back = result.slice(halfway, result.length);
38 return xor(front, back);
41export const generateCode = async privKeyHex => {
42 const privKey = hexToArrayBuffer(privKeyHex);
43 const salt = hexToArrayBuffer('73736170');
44 const hash = shax(privKey);
45 const result = shaf(hash, salt);
46 const half = result.slice(0, result.length / 2);
48 return hex2patp(buf2hex(half));
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list