| 1410 | |
| 1411 | describe('generateHash', () => { |
| 1412 | async function computeNativeSha256(value: string): Promise<string> { |
| 1413 | const msgUint8 = new TextEncoder().encode(value); |
| 1414 | const hashBuffer = await crypto.subtle.digest('SHA-256', msgUint8); |
| 1415 | const hashArray = Array.from(new Uint8Array(hashBuffer)); |
| 1416 | return hashArray.map((b) => b.toString(16).padStart(2, '0')).join(''); |
| 1417 | } |
| 1418 | |
| 1419 | it('should generate standard SHA-256 hashes matching Web Crypto specs', async () => { |
| 1420 | const testCases = [ |