lune icon indicating copy to clipboard operation
lune copied to clipboard

Implement hashing algorithms + HMac support

Open Dekkonot opened this issue 9 months ago • 0 comments

Implements the basics of hashing algorithm support, along with hmac.

Does so via 2 new functions:

serde.hmac(algorithm: HashAlgorithm, message: string | buffer, secret: string | buffer): string
serde.hash(algorithm: HashAlgoritm, message: string | buffer): string

This implementation is currently untested, so there be dragons. I'm opening this PR as the underlying implementation is finished and I'm ready for review on that front. Once it's clear that we're happy with the implementation, I'll move onto the busy work like tests and updating type docs.

Algorithm Choice

After the discussion in #105, I elected to include sha1, sha2, sha3, blake3, and md5 for this implementation. This is mostly for practical reasons: algorithms for passwords are more complicated, and other algorithms (like xxhash) don't HMAC well.

I do want to call special attention to GxHash, as it uses aes and thus requires us to mess with our target features if we want to include it. I'm not going to make the call for that, since I'm not Lune's maintainer.


If merged would close #105.

Dekkonot avatar May 11 '24 01:05 Dekkonot