Skip to content

Conversation

@wemeetagain
Copy link
Member

@wemeetagain wemeetagain commented May 15, 2024

  • Create async variant of the hash function

TODO

  • benchmarks to determine if this is a good idea (If it takes 2ms to go to/from the uv thread, and the compute is measured in ns, then this is bad)

@wemeetagain wemeetagain requested a review from matthewkeil May 15, 2024 13:31
@wemeetagain wemeetagain changed the title feat: implement async variant feat: implement async hash May 15, 2024
Comment on lines +60 to +67
it("should asyncHash similarly to crypto.createHash('sha256')", async () => {
for (let i = 1; i <= 16; i++) {
test(`No of Chunks=${i}`, () => {
for (let j = 0; j < 255; j++) {
const input = Buffer.alloc(CHUNK_SIZE * i, j);
const output1 = Buffer.alloc((CHUNK_SIZE / 2) * i);
const output2 = Buffer.alloc((CHUNK_SIZE / 2) * i);
for (let j = 0; j < 255; j++) {
const input = Buffer.alloc(CHUNK_SIZE * i, j);
expectEqualHex(await hashAsync(input), nodeCryptoHash(input));
}
}
});
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just split this into a separate test so there is only one expect per test. Also cleaned up the output, i added a describe on PR#3 to show the chunk size but seems unnecessary in retrospect

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants