What hash algorithms are supported by modern Javascript?
I don't believe the browser has any built-in functionality built in, but there are some well-documented implementations.
The best I have found is http://code.google.com/p/crypto-js/ which is available via CDN and supports:
- MD5
- SHA-1
- SHA-256
- AES
- DES
- Rabbit
- MARC4
- HMAC
- HMAC-MD5
- HMAC-SHA1
- HMAC-SHA256
- PBKDF2
If the security issue makes sense, use an algorithm that hasn't been broken (s) yet and is less susceptible to various forms of attack (wikipedia has a nice breakdown at the bottom of this article ).
Based on the lack of answers to this question , it looks like this is not a built-in browser feature. Wish I could, but I've seen problems with browser usage. For example, if a flaw is found in an algorithm, it would be difficult to move users to the new algorithm until you know that all of its browsers support it (and they've updated). If you are in control of the hashing algorithm, then you can deploy a new script whenever you want.
source to share
I'm not sure about built-in hash implementations other than what is already used for associative arrays, but here are some examples of implementation with code.
SHA
- http://www.movable-type.co.uk/scripts/sha1.html
- http://www.webtoolkit.info/javascript-sha1.html
- http://jssha.sourceforge.net/
MD5 (with some others included)
source to share
Movable Type posted a js implementation of SHA1 here: http://www.movable-type.co.uk/scripts/sha1.html
I'm sure there are many other implementations out there.
source to share