1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import { base16, base58 } from "npm:@scure/base";
const input = bytes(`
a0 86 01 00 00 00 00 00
`);
function uint64(data: Uint8Array) {
let result = 0n;
for (let i = 0; i < data.length; i++) {
result += BigInt(data[i]) << BigInt(8 * i);
}
return result;
}
console.log(uint64(input));
function bytes(str: string): Uint8Array {
return base16.decode(str.replaceAll(/\s/g, "").toUpperCase());
}
Val Town is a social website to write and deploy JavaScript.
Build APIs and schedule functions from your browser.
Comments
Nobody has commented on this val yet: be the first!
July 1, 2024