Calculating SHA-1 in the Browser

Florian Hämmerle
1 min readMay 24, 2018

Important: SHA-1 is considered weak, has been broken and should be avoided for cryptographic applications!

By Volkan Olmez on Unsplash

Calculating the SHA-1 hash of a string can be useful for different reasons. As noted above, you shouldn’t use it for cryptographic applications but it still can (and is) used for integrity and consistency. For example, git uses SHA-1 hashes for commits to ensure consistency. But it also comes in handy whenever you’re not really interested in the data itself but only need some way to check whether two entities have the same data. You can then just exchange the SHA-1 of the data (which is usually much shorter than the data itself) and check whether your copy is the same as the others.

Calculating the SHA-1 of a string is quite easy in most browsers — even IE11 provides the necessary APIs.

--

--

Florian Hämmerle

raised & based in the Alps • co-founded a digital studio • former CPO at a news company • partner at a software consultancy • into products and innovation