Some tiny hash functions in javascript
JavaScript Makefile
Permalink
Failed to load latest commit information.
.gitignore Update makefile to include closure etc; tweak tests a lot Apr 10, 2014
.travis.yml Travis-CI Nov 23, 2014
Makefile
README.md I am an idiot and should learn how to Markdown. Jun 4, 2015
md5-min.js Compile @heavensrevenge's changes (yay bytes!); also add some whitespace Aug 28, 2014
md5.js Compile @heavensrevenge's changes (yay bytes!); also add some whitespace Aug 28, 2014
sha1-min.js Save a few more bytes in sha1/256; add more tests for big vectors Dec 13, 2015
sha1.js Save a few more bytes in sha1/256; add more tests for big vectors Dec 13, 2015
sha256-min.js Save a few more bytes in sha1/256; add more tests for big vectors Dec 13, 2015
sha256.js Save a few more bytes in sha1/256; add more tests for big vectors Dec 13, 2015
test.js Save a few more bytes in sha1/256; add more tests for big vectors Dec 13, 2015

README.md

JavaScript Hash Functions

Some JavaScript implementations of common hash functions (MD5, SHA-1 and SHA-256) designed to be compressed into the smallest size possible.

I can't entirely guarantee that they'll absolutely always work exactly as they should, so it's probably not the best idea to use them in anything absolutely mission-critical. That said, they do seem to work fine for me wherever I use them. And if you do find something wrong, open an issue on GitHub and I'll do my best to fix it.

Licence and Usage

These scripts are licensed under the ☺ licence, so basically you're free to use them however you please - feel free to use or modify them in whatever way you like. You don't have to explicitly credit me (but if you do then I won't complain), but just don't pass them off as entirely your own, ok? That's just not cool.

But Why?

To begin with, because I needed a smallish MD5 that wasn't poorly written (lots of the others out there leaked globals), but nowadays it's pretty much just because I can.

And How?

Well, I started out with a mashup of the pseudocode on the respective wikipedia pages for the functions along with helper functions I found somewhere on the internet for converting strings to byte arrays etc, then bashed them every which-way I could with functionally-equivalent rearrangements to make the size smaller however I could think. Just don't try to get me to explain what any of it does any more.

Shout out to RyanC for spotting a couple of bugs where I'd been a moron and over-optimised.