SHAmwow/README.md

37 lines
1.7 KiB
Markdown
Raw Permalink Normal View History

2017-08-30 00:36:14 +00:00
# SHAmwow
2017-09-04 02:22:24 +00:00
Sometimes you just want to understand how your hashing algorithms work, so you implement them yourself.
2017-08-30 00:36:14 +00:00
2017-09-04 02:21:46 +00:00
It should go without saying that this was just for fun, and you should never, ever, _ever_ roll your own cryptography primatives for any purpose other than education!
2017-08-30 00:36:14 +00:00
2018-01-08 23:46:25 +00:00
## Talk
I gave a talk on this project at [Papers We Love NYC](http://paperswelove.org/2017/video/david-ashby-shamwow/)! The [PDF](https://github.com/deltamualpha/shamwow/blob/master/slides.pdf), [Keynote file](https://github.com/deltamualpha/shamwow/blob/master/slides.key), and [PDF-with-nodes](https://github.com/deltamualpha/shamwow/blob/master/slides-with-notes.pdf) of the slides are also in this repo.
2017-09-04 02:21:46 +00:00
## sha1
2017-08-30 00:36:14 +00:00
2017-09-04 02:21:46 +00:00
The sha1 function in `shamwow.rb` implements the SHA1 hashing function in Ruby, outputting the 160-bit hash as a hexadecimal string.
2017-08-30 00:36:14 +00:00
2017-09-04 02:21:46 +00:00
### sources
* wikipedia's pseudocode breakdown: <https://en.wikipedia.org/wiki/SHA-1#Examples_and_pseudocode>
## sha2
The sha2 function in `shamwow.rb` implements the SHA-256 hashing function in Ruby, outputting the 256-bit hash as a hexadecimal string.
### Sources
2017-08-30 00:36:14 +00:00
* the actual spec: <http://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.180-4.pdf>
* wikipedia's pseudocode breakdown: <https://en.wikipedia.org/wiki/SHA-2#Pseudocode>
* a JS implementation that helped as I was debugging some boneheaded mistakes: <http://www.movable-type.co.uk/scripts/sha256.html>
2017-09-04 02:21:46 +00:00
## Tests
`shamwow_test.rb` contains a few sanity tests for the bit-rotation functions and for the hashes themselves, testing against the output of the `Digest` gem in the standard library.
2017-08-30 00:36:14 +00:00
## Obligatory
[![ShamWOW](https://img.youtube.com/vi/F3lrhPeK6gU/0.jpg)](https://www.youtube.com/watch?v=F3lrhPeK6gU)