Add support for specifying the output length

Hi Nathan, I'm kind of scared pulling this since I'm not too familiar with hash functions. However I've made some quick tests and it seems to work as expected, nonetheless take a look and let me know what you think.