Skip to content

Allow Hash object reuse #45031

Closed as not planned
Closed as not planned

Description

@kwasimensah

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

Activity

  1. added
    feature request
    on Oct 16, 2022
  2. kwasimensah commented on Oct 16, 2022

    @kwasimensah
    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.

  3. mscdex commented on Oct 16, 2022

    @mscdex
    Contributor

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

  4. kwasimensah commented on Oct 16, 2022

    @kwasimensah
    Author
  5. kwasimensah commented on Oct 16, 2022

    @kwasimensah
    Author

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

  6. bnoordhuis commented on Oct 20, 2022

    @bnoordhuis
    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 🤷

  7. added
    crypto
    on Oct 20, 2022
  8. moved this to Pending Triage in Node.js feature requestson Oct 22, 2022
  9. tniessen commented on Nov 6, 2022

    @tniessen
    Member

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

  10. github-actions commented on May 6, 2023

    @github-actions
  11. added
    stale
    on May 6, 2023
  12. added
    never-stale
    and removed
    stale
    on May 12, 2023
  13. removed
    never-stale
    on Sep 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    cryptofeature request

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions