Is a hmac-sha1 hash always 20 bytes long? Python code
Asked Answered
S

3

8

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())
Sleeve answered 30/7, 2011 at 1:31 Comment(1)
yes it isBunyan
F
11

All hashing functions have fixed length outputs. SHA1 is 160 bits, or 20 bytes.

Floaty answered 30/7, 2011 at 1:35 Comment(0)
O
2

Yes. SHA1 HMAC hash is always 160 bits (e.g. 20 bytes).

Ostend answered 30/7, 2011 at 1:35 Comment(0)
N
2

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."

Nihi answered 30/7, 2011 at 1:37 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.