Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Hexdigest on python 2.6 and 2.7
############################################################################################
>>> sys.version
'2.7.3 (default, Aug 9 2012, 17:23:57) \n[GCC 4.7.1 20120720 (Red Hat 4.7.1-5)]'
>>> for algo in hashlib.algorithms:
... print '{algo} has hexdigest()'.format(instance=getattr(hashlib, algo)(), algo=algo)
...
md5 has hexdigest()
sha1 has hexdigest()
sha224 has hexdigest()
sha256 has hexdigest()
sha384 has hexdigest()
sha512 has hexdigest()
############################################################################################
>>> sys.version
'2.6.5 (r265:79063, Oct 1 2012, 22:04:36) \n[GCC 4.4.3]'
>>> for algo in ('md5', 'sha1', 'sha224', 'sha256', 'sha384', 'sha512'):
... print '{algo} has hexdigest()'.format(instance=getattr(hashlib, algo)(), algo=algo)
...
md5 has hexdigest()
sha1 has hexdigest()
sha224 has hexdigest()
sha256 has hexdigest()
sha384 has hexdigest()
sha512 has hexdigest()
############################################################################################
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.