Hash String Size

In python, I use the following code to create a hash for user passwords:

self.password = hmac.new(security_key, raw_password, sha1).hexdigest()

Now I would like to store this value in the database. What size should be my database column? This is similar to the digest_size property, but does not know which object or class has such a property. sha1 does not have.

+5
source share
2 answers

hmac . sha1, 20 RFC2104. hexdigest() . 1 = 2 , 40 . char (40).

+3

- sha-1 20 . ( RFC2104, hmac python module docs: "... L - (L = 16 MD5, L = 20 SHA-1)." )

:

import hashlib;
H = hashlib.sha1("blahblah");
print(H.digest_size);
+1

All Articles