MCPcopy Create free account
hub / github.com/dfinity/orbit / arrayBufferToHashHex

Function arrayBufferToHashHex

apps/wallet/src/utils/crypto.utils.ts:7–14  ·  view source on GitHub ↗
(
  buffer: ArrayBuffer,
  algorithm: AlgorithmIdentifier = 'SHA-256',
)

Source from the content-addressed store, hash-verified

5};
6
7export const arrayBufferToHashHex = async (
8 buffer: ArrayBuffer,
9 algorithm: AlgorithmIdentifier = 'SHA-256',
10): Promise<string> => {
11 const hash = await crypto.subtle.digest(algorithm, buffer);
12
13 return arrayBufferToHex(hash);
14};
15
16export const hexStringToArrayBuffer = (hexString: string): ArrayBuffer => {
17 // Ensure the hex string has an even length

Callers 1

Calls 1

arrayBufferToHexFunction · 0.85

Tested by

no test coverage detected