Lewis Moten

JavaScript SHA-1

A hash function in the browser, April 2001

A card showing the SHA-1 digest of abc.

A JavaScript port of the SHA-1 hash, published in April 2001, before its collision weaknesses were known.

Executive summary

Why it exists

The function makes a 160-bit digest, 40 hex digits, from a message of any length, and in 2001 there was little hashing code for the browser.

Outcome

Years later, while contracting at a company, I found my own code in their commercial codebase with someone's SHA-256 additions on top. I told them. They checked their history, confirmed it predated me, and announced it to every team.

My role

Author.

Technical overview

How it works

A JavaScript port of SHA-1 that I published in April 2001.

Stack

  • JavaScript
  • Cryptography