Hello,
Right now MD5 lives in the Crypto module, while SHA1 lives in the Digest module.
I think the latter would be a better fit for MD5. Further, I'd love to see the MD5 API to mirror the one of SHA1:
| Digest::SHA1 | Crypto::MD5 |
|---------|--------|
| Is a module | Is a class |
| Context is private | Context is public |
| .digest(String | Bytes) | Doesn't exist |
| .hexdigest(String | Bytes) No underscore | .hex_digest(String | Bytes) Has underscore |
| Doesn't exist | .hex_digest() with yield |
| .base64digest(String | Bytes) | Doesn't exist |
I'd thus like to do:
MD5 to Digesthex_digest to hexdigestI could work on this, though I'd like to get community feedback first before wasting everyones time :)
Cheers!
great analysis and breakdown of the differences between the two!
fwiw in Ruby it's Digest::MD5 and Digest::SHA1. :+1: for mirroring the APIs.
edit: forgot to +1
I'm always hesitant to use crystal implementations of crypto functions, mainly because of the possibility of timing attacks. AFAIK openssl uses mostly hand-written assembly to help ensure this constant-time.
MD5 has nothing to do in Crypto land. Digest is a better place.
Thanks y'all for the positive feedback. I'll work on it tomorrow (Tuesday) then.
As #4037 was merged (Thanks!), I'll close this.
Most helpful comment
MD5 has nothing to do in Crypto land. Digest is a better place.