Support multiple encodings
Currently node_hash only supports the 'hex' encoding. So it's impossible to use 'ascii' or 'utf8'.
Should be an easy fix: Add encoding to exported methods, default to 'hex' if nothing passed.
I'm a little confused what the API would like look for this.
Could you show me some sample usage syntax?
Rly? ok.
https://gist.github.com/800931
I'm not sure how I could do the arguments parsing without making the salts "utf-8", "ascii" and "hex" reserved? Would that be your solution?
How can I tell the difference between:
var md5 = hash.md5(user_password, 'utf8');
and
var md5 = hash.md5(user_password, 'utf8');
, where one is telling me to use the default settings with a salt of "utf8" and the other is telling me to use utf-8 encoding with no salt?
pass null as the second argument?
I think,
var md5 = hash.md5(user_password, 'utf-8');
and
var md5 = hash.md5(user_password, null, 'utf8');
makes the most sense, where in the first example, 'utf-8' happens to be the salt. This makes the api require you to always send a salt, forcing you to send null if you ignored using a salt
I would reserve the strings. using 'utf-8' as an encoding is not the same as using 'utf8' you could expose the strings as vars to help people:
var md5 = hash.md5(user_password, hash.utf8);
I would open up a larger discussion on the nodejs-dev list about pulling this into core if ambiguity is really a problem for you. I still think this belongs in core if Ry mentioned it as such.