Is a hmac-sha1 hash always 20 bytes long? Python code
10,477
Solution 1
All hashing functions have fixed length outputs. SHA1 is 160 bits, or 20 bytes.
Solution 2
Yes. SHA1 HMAC hash is always 160 bits (e.g. 20 bytes).
Solution 3
SHA-1 always returns 160 bits, or 20 bytes.
http://www.itl.nist.gov/fipspubs/fip180-1.htm
"For a message of length < 2^64 bits, the SHA-1 produces a 160-bit condensed representation of the message called a message digest."
Related videos on Youtube
![Admin](/assets/logo_square_200-5d0d61d6853298bd2a4fe063103715b4daf2819fc21225efa21dfb93e61952ea.png)
Author by
Admin
Updated on June 25, 2022Comments
-
Admin about 2 years
Is the digest always 20 bytes long? len(hashed.digest()) seems to always be 20.
hashed = hmac.new(key, signature_base_string, sha) print hashed.digest() print len(hashed.digest()) i = 0 for c in hashed.digest(): i = i + 1 print ord(c) print base64.b64encode(hashed.digest())
-
President James K. Polk almost 13 years
-