Dependency upgrade + lib_um_crypto_rust (#78)

Co-authored-by: 鲁树人 <lu.shuren@um-react.app>
Co-committed-by: 鲁树人 <lu.shuren@um-react.app>
This commit is contained in:
鲁树人
2024-09-24 22:19:30 +00:00
committed by 鲁树人
parent c5bc436ab2
commit 58c96f264b
65 changed files with 4160 additions and 4025 deletions

15
src/util/hex.ts Normal file
View File

@@ -0,0 +1,15 @@
export function formatHex(value: number, len = 8) {
return '0x' + (value | 0).toString(16).padStart(len, '0');
}
export function hex(value: Uint8Array): string {
return Array.from(value, (byte) => byte.toString(16).padStart(2, '0')).join('');
}
export function unhex(value: string): Uint8Array {
const bytes = [];
for (const [byte] of value.matchAll(/[0-9a-fA-F]{2}/g)) {
bytes.push(parseInt(byte, 16));
}
return new Uint8Array(bytes);
}