Add bufferToHex, re-export some stuff from nostr-editor

This commit is contained in:
Jon Staab
2025-05-09 12:31:14 -07:00
parent 96b1f8872c
commit d2ba0f6642
4 changed files with 12 additions and 2 deletions
+10
View File
@@ -1551,3 +1551,13 @@ export const hexToBech32 = (prefix: string, hex: string) =>
*/
export const bech32ToHex = (b32: string) =>
utf8.encode(bech32.fromWords(bech32.decode(b32 as any, false).words))
/**
* Converts an array buffer to hex format
* @param buffer - ArrayBuffer string to convert
* @returns Hex encoded string
*/
export const bufferToHex = (buffer: ArrayBuffer) =>
Array.from(new Uint8Array(buffer))
.map(b => b.toString(16).padStart(2, "0"))
.join("")