0

I would like to find an ES5 SHA-1 string hashing algorithm. I am having trouble with finding a more official source. My desire would be to usecrypto.subtle.digest("SHA-1", new TextEncoder("utf-8").encode(str));, but is seems there are many problems using this in IE11 with crypto, and the shims necessary for promises.

If anyone knows of a self-contained string SHA-1 hashing algorithm for IE11 written in ES5, I'd be most grateful.

NOTE: I know some of you are going to ask, so I'll just say I am using it for partial hash lookup, very similar to the way "have I been pwned" works. SHA-1 has long since been defunc as a secure hash, so I am not using it for that.

brightmatter
  • 162
  • 1
  • 10
  • 1
    There could be useful links in [Simple (non-secure) hash function for JavaScript?](https://stackoverflow.com/questions/6122571/simple-non-secure-hash-function-for-javascript) – Andrew Morton Dec 08 '20 at 16:04
  • 1
    I tried to search for official documentation for the **ES5 SHA-1 Hash** algorithm but I did not get any official information about it. I found this Wikipedia [article](https://en.wikipedia.org/wiki/SHA-1) about SHA-1. You may need to convert its code to ES5 to make it work with the IE browser. – Deepak-MSFT Dec 09 '20 at 02:26
  • 1
    I think your best bet is to use Babel (or similar) to transpile a modern SHA1 algorithm to ES5, like the one here: https://coursesweb.net/javascript/sha1-encrypt-data_cs (note: have not tested if this particular one works properly, just the first self-contained snippet I found). – Luca_Scorpion Jan 20 '21 at 11:50
  • https://code.google.com/archive/p/crypto-js/downloads it is right here. – brightmatter Jan 22 '21 at 22:51

0 Answers0