feat(browser): Implement fallback SHA256 for non-HTTPS environments and enhance browser tests for consistent hashing
This commit is contained in:
@ -62,4 +62,16 @@ tap.test('md5FromString should throw in browser environment', async () => {
|
||||
await expect(smarthash.md5FromString('test')).rejects.toThrow();
|
||||
});
|
||||
|
||||
tap.test('sha256 produces consistent results across environments', async () => {
|
||||
// Test that our implementation produces the same hash as Node.js crypto
|
||||
const testHash = await smarthash.sha256FromString('test');
|
||||
const expectedHash = '9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08';
|
||||
expect(testHash).toEqual(expectedHash);
|
||||
|
||||
// Test with different string
|
||||
const testHash2 = await smarthash.sha256FromString('hello world');
|
||||
const expectedHash2 = 'b94d27b9934d3e08a52e52d7da7dabfac484efe37a5380ee9088f7ace2efcde9';
|
||||
expect(testHash2).toEqual(expectedHash2);
|
||||
});
|
||||
|
||||
export default tap.start();
|
Reference in New Issue
Block a user