Skip to content

Latest commit

 

History

History
87 lines (56 loc) · 2.55 KB

sha1.rst

File metadata and controls

87 lines (56 loc) · 2.55 KB

SHA-1

SHA-1 produces the 160 bit digest of a message. For example:

>>> from Crypto.Hash import SHA1
>>>
>>> h = SHA1.new()
>>> h.update(b'Hello')
>>> print h.hexdigest()

SHA stands for Secure Hash Algorithm.

Warning

This algorithm is not considered secure. Do not use it for new designs.

Warning

SHA-1 is vulnerable to length-extension attacks, which are relevant if you are computing the hash of a secret message.

For instance, let's say you were planning to build a cheap MAC by concatenating a secret key to a public message m (bad idea!):


h = SHA-1(m||k)

By only knowing the digest h and the length of m and k, the attacker can easily compute a second digest h':


h′ = SHA-1(m||p||z)

where p is a well-known bit string and the attacker can pick a bit string z at will.