Repository navigation
crypto: add crypto.hash - #42233
crypto: add crypto.hash#42233tniessen wants to merge 1 commit into
Conversation
|
Review requested:
|
I realize that for hashing, the overhead of async calls might not be worth it, but it does worry me a bit that this would encourage consistently using synchronous calls for this when thatβs a pattern that we donβt generally want to encourage. |
π€€ so much potential, the same can be done for |
|
Closing since #51044 was merged. |
The goal here is to provide an alternative to
crypto.Hashandcrypto.webcrypto.subtle.digestthat is faster and simpler to use.crypto.Hashis much faster thancrypto.webcrypto.subtle.digestaccording tobenchmark/crypto/oneshot-hash.js:The current implementation of
crypto.hashis about 20 percent faster thancrypto.Hashfor data smaller than 1 KiB:There is still room for improvement. For example, it still unnecessarily calls into C++ twice.
One thing I am not sure about is encoding. I think an additional
encodingparameter for the output would make sense, since producinghexor evenbase64digests is extremely common. That leaves no room for an input encoding, which is why strings are currently not allowed as inputs.We can also add a
callbackargument (similar tocrypto.signin #26611).Refs: #26748