Hacker News new | ask | show | jobs
by ConcernedCoder 1520 days ago
The wikipedia article spells it out pretty clearly, and the pseudo-code is easily translated into any language, here it is in JavaScript if anyone is interested:

sha-256: https://github.com/jeffallen6767/sha-256-js/blob/master/src/...

Once you understand the concept that most of these algos are simply dividing the input into computer-friendly sized blocks and then stacking and manipulating these bits in 3d space like a rubics cube, then the whole thing becomes a bit easier to understand.

Here's a few more for comparison:

sha-1: https://github.com/jeffallen6767/sha-1-js/blob/master/src/sh...

md5: https://github.com/jeffallen6767/md5-js/blob/master/src/md5....

keccak: https://github.com/jeffallen6767/keccak-p-js/blob/master/src...

side note, I also ended-up implementing the keccak algo in c for open cl usage, because I wanted to see if I could use it in parallel on my graphics card from nodejs ( spoiler: it's indeed possible ):

https://github.com/jeffallen6767/chain/blob/master/src/minin...

Please forgive my terrible programming style, this was done years ago...