dominictarr/crypto-browserify — pull request #22 by lsegal (2013-10-09 01:52:46+00:00)
Title: Add support for hashing Unicode data by using Buffers

Previously, all hashing algorithms were converting string data to binary using a naive approach that did not support non-ASCII input. This change converts input into a Buffer which properly handles Unicode data. This change also fixes the interface on createHash and createHmac to properly return a Buffer object by default, which the Node.js API does.

* Updated tests to ensure that hash functions work with Unicode
* createHash()/createHmac() now returns a Buffer to match Node.js API
* Refactored index.js and hash implementations to reduce duplication

Note that a side-benefit of using Buffers also means that you no longer need to have separate implementations of base64, hex, etc. encodings, since these are all supported by Buffer itself. This reduces code size and means you can support more encodings.