digitalmars.D.announce - SHA-1 and SHA-256 in D (for phobos2?)
- Adam Ruppe (19/19) Nov 26 2009 I made up an implementation of SHA-1 and SHA-256 today, based on the
I made up an implementation of SHA-1 and SHA-256 today, based on the algorithm in the Wikipedia article. It passes a small unittest, comparing its output to the linux sha utilities for the same input. I don't know how good the speed is, but I tried to avoid unnecessary copying, and speed can always be improved later anyway. Here it is: http://arsdnet.net/dcode/sha.d I think Phobos only offers MD5, so this might be a good addition. I'm thinking the std.md5 module could be renamed to something like std.hash and include the current MD5 code, the SHA code, and whatever else we want down the line. My code still has a few hacky casts in it - I'm trying to convert it to take input ranges, but haven't quite mastered that yet. It works fine with built in strings at least, and seems to be passing with InputByChar(stdin), but only because of a cast. Also, I plan to offer an API similar to what std.md5 has, instead of just the single standalone functions I have now. I don't know when I'll have the time to finish it though, but here's the code for anyone who might find it useful.
Nov 26 2009