diff options
author | polwex <polwex@sortug.com> | 2025-07-16 16:54:11 +0700 |
---|---|---|
committer | polwex <polwex@sortug.com> | 2025-07-16 16:54:11 +0700 |
commit | 43db7d9fdaf9877325aae02cdad9b7bf3adc01e9 (patch) | |
tree | ad38aeed58b0fbb88031beb164ef1e321d85c2a9 /lib/utils | |
parent | e7d4e342d112f89bebeb08aaa502227ca7747a8c (diff) |
XOR encryption working!!! fuck yeah!!!
Diffstat (limited to 'lib/utils')
-rw-r--r-- | lib/utils/bit.ts | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/lib/utils/bit.ts b/lib/utils/bit.ts index bc1ed1a..e54cd41 100644 --- a/lib/utils/bit.ts +++ b/lib/utils/bit.ts @@ -1,5 +1,7 @@ import { sha256 } from "urbit-key-generation/src/utils"; +import "core-js/actual/typed-array"; + export function shas(buf: Buffer, salt: Buffer) { return sha256(xor(salt, sha256(buf))); } @@ -33,3 +35,12 @@ export function hex2buf(hex: string) { export function buf2hex(buf: Uint8Array) { return Buffer.from(buf).reverse().toString("hex"); } +export function hex2bytes(hex: string) { + const clean = hex.replace(/^0x/i, ""); + const ba = Uint8Array.fromHex(clean); + return ba; +} + +export function bytes2hex(ta: Uint8Array) { + return ta.toHex(); +} |