Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow Hash object reuse #45031

Open
kwasimensah opened this issue Oct 16, 2022 · 7 comments
Open

Allow Hash object reuse #45031

kwasimensah opened this issue Oct 16, 2022 · 7 comments
Labels
crypto Issues and PRs related to the crypto subsystem. feature request Issues that request new features to be added to Node.js. never-stale Mark issue so that it is never considered stale

Comments

@kwasimensah
Copy link

What is the problem this feature will solve?

#25857 (comment)

I'm creating the hash of many small objects and need to keep track of these individual hashes so #29903 doesn't work.

My specific use case is that I'm hashing directory layouts to setup a file layout that's optimal about symlinking entire directories when its filled with symlinked entries that all point to the same source directory. I can get into specifics if that matters.

What is the feature you are proposing to solve the problem?

crypto.Hash.reset() - reset the internal state of the hasher and allows it to be reused with any new allocations

What alternatives have you considered?

-not use crypto.hash in this case and write my own hasher
-create a native add on that lets me manage to hash context according to my needs

@kwasimensah kwasimensah added the feature request Issues that request new features to be added to Node.js. label Oct 16, 2022
@kwasimensah
Copy link
Author

This was discussed before at #25857 but with #25857 (comment) it seems there was an assumption that people don't need to hash a lot of small strings.

There were worries about what the UX of allowing resets of this object but there seems to be several APIs in node that have a reset function now.

@mscdex
Copy link
Contributor

mscdex commented Oct 16, 2022

Have you actually determined that createHash() is bottlenecking your application?

@kwasimensah
Copy link
Author

kwasimensah commented Oct 16, 2022 via email

@kwasimensah
Copy link
Author

I'm happy to try and contribute this myself if people are ok with the idea of adding this function

@bnoordhuis
Copy link
Member

I think a .reset() method would be okay.

The lack of orthogonality w.r.t. HMAC or Cipher (who you can't meaningfully reset) is a little jarring but 🤷

@bnoordhuis bnoordhuis added the crypto Issues and PRs related to the crypto subsystem. label Oct 20, 2022
@targos targos moved this to Pending Triage in Node.js feature requests Oct 22, 2022
@tniessen
Copy link
Member

tniessen commented Nov 6, 2022

IMHO an approach such as #42233 would be better assuming that this is about hashing small amounts of data.

@github-actions

This comment was marked as outdated.

@github-actions github-actions bot added the stale label May 6, 2023
@tniessen tniessen added never-stale Mark issue so that it is never considered stale and removed stale labels May 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
crypto Issues and PRs related to the crypto subsystem. feature request Issues that request new features to be added to Node.js. never-stale Mark issue so that it is never considered stale
Projects
Status: Awaiting Triage
Development

No branches or pull requests

4 participants