( buffer: ArrayBuffer, algorithm: AlgorithmIdentifier = 'SHA-256', )
| 5 | }; |
| 6 | |
| 7 | export 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 | |
| 16 | export const hexStringToArrayBuffer = (hexString: string): ArrayBuffer => { |
| 17 | // Ensure the hex string has an even length |
no test coverage detected