What hash algorithms are supported by modern Javascript?

I would like to generate SHA1 or similar hashes using client-side Javascript only. In other words, using Javascript engines provided by IE, FF and Webkit. I am wondering what implementations of the hash are there?

+3


source to share


3 answers


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.

+5


source


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



MD5 (with some others included)

+3


source


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.

0


source







All Articles