Does the hmac-sha1 hash always have a length of 20 bytes? Python code

Is a digest only 20 bytes long? len (hashed.digest ()) is always always 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()) 
+6
source share
3 answers

All hash functions have fixed lengths. SHA1 is 160 bits or 20 bytes.

+11
source

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

+1
source

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, SHA-1 creates a 160-bit compressed representation of the message, called a message digest."

+1
source

Source: https://habr.com/ru/post/893921/


All Articles