You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
It’s not a bottle neck but it’s showing up enough on cpu-prof profiles
that it’d be great to remove it.
I’m doing some profiling/writing benchmarks and this came up as a possible
win
Activity
kwasimensah commentedon Oct 16, 2022
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 commentedon Oct 16, 2022
Have you actually determined that
createHash()is bottlenecking your application?kwasimensah commentedon Oct 16, 2022
kwasimensah commentedon Oct 16, 2022
I'm happy to try and contribute this myself if people are ok with the idea of adding this function
bnoordhuis commentedon Oct 20, 2022
I think a
.reset()method would be okay.The lack of orthogonality w.r.t.
HMACorCipher(who you can't meaningfully reset) is a little jarring but 🤷tniessen commentedon Nov 6, 2022
IMHO an approach such as #42233 would be better assuming that this is about hashing small amounts of data.
github-actions commentedon May 6, 2023