More SHA in Erlang
January 3rd, 2009 | Published in code, erlang | 5 Comments | Bookmark on Pinboard.in
Yesterday I posted a SHA-256 Erlang module, but I figured since other SHA algorithms are similar, I might as well finish the job. I grabbed the Secure Hash Standard and went to work.
The resulting new module is named sha2 and it implements SHA-224, SHA-256, SHA-384, and SHA-512.
- Code
- Light documentation
- Tests are included in the module but you get the test vectors here
- It’s open source, BSD license
I hope you find it useful.
January 5th, 2009 at 9:42 am (#)
Thanks a lot! I was definitely looking for a better sha module for erlang just this week and it seems this comes in right in time.
This will prove itself to be really useful, and if good enough, I hope it can eventually make it into the standard erlang library.
January 7th, 2009 at 7:08 am (#)
Thanks for keeping Erlang “on the curve” :)
January 8th, 2009 at 7:18 am (#)
I wrote a SHA-1 library for Erlang in 2007, just to play with pattern matching:
http://journal.batard.info/post/2007/07/19/erlang-sha-1-library
I am aware of crypto:sha/1, this was not meant to be used, but rather just a demo.
I’m writing as the performance of my module was astoundingly bad; is yours better? Have you tried hashing even just a 50MB file?
Looking forward to hearing from you,
Nicolas.
January 8th, 2009 at 10:51 am (#)
@Nicolas: no, I don’t think performance would be all that great for a 50MB file. One of the test vectors is 393216 bytes, for example, and it takes 4.33s to run through SHA-256. Given that the performance appears to be fairly linear with respect to the input message size, I think it would take over 10 minutes to deal with a 50MB file.
Still, the performance is better than nothing, which is the support the crypto module currently gives us for these functions.
January 22nd, 2009 at 8:37 am (#)
Thanks man, I was about to write a C driver because I was getting desperate.