@scintilla-network/hashes
Version:
Enhanced hash functions for Scintilla and broader crypto / blockchain use
30 lines (26 loc) • 1.07 kB
JavaScript
import { describe, it, expect } from 'vitest';
import { sha512 } from './sha512.js';
import { TEST_VECTOR } from '../test/vectors.js';
describe('SHA-512', () => {
it('should hash empty message correctly', () => {
const hash = sha512(TEST_VECTOR.emptyMessage);
expect(hash).toBeInstanceOf(Uint8Array);
expect(hash.length).toBe(64);
});
it('should hash test message correctly', () => {
const hash = sha512(TEST_VECTOR.message);
expect(hash).toBeInstanceOf(Uint8Array);
expect(hash.length).toBe(64);
});
it('should handle various input formats', () => {
const stringHash = sha512('test');
const hexHash = sha512('deadbeef');
const jsonHash = sha512({ test: 'value' });
expect(stringHash).toBeInstanceOf(Uint8Array);
expect(hexHash).toBeInstanceOf(Uint8Array);
expect(jsonHash).toBeInstanceOf(Uint8Array);
expect(stringHash.length).toBe(64);
expect(hexHash.length).toBe(64);
expect(jsonHash.length).toBe(64);
});
});