def _get_hash_types():
hash_types = OrderedDict()
try:
algorithms = hashlib.algorithms_available
except AttributeError:
algorithms = hashlib.algorithms
if 'md5' in algorithms:
hash_types['MD5'] = hashlib.md5
if 'sha1' in algorithms:
hash_types['SHA1'] = hashlib.sha1
if 'sha256' in algorithms:
hash_types['SHA256'] = hashlib.sha256
if 'sha512' in algorithms:
hash_types['SHA512'] = hashlib.sha512
hash_types['BLAKE2b_256'] = partial(BLAKE2b.new, digest_bits=256)
hash_types['BLAKE2b_512'] = partial(BLAKE2b.new, digest_bits=512)
hash_types['RIPEMD160'] = RIPEMD160.new
# The ones from hashlib are faster
# hash_types['MD5'] = MD5.new
# hash_types['SHA1'] = SHA1.new
# hash_types['SHA256'] = SHA256.new
# hash_types['SHA512'] = SHA512.new
hash_types['SHA3_256'] = SHA3_256.new
hash_types['SHA3_512'] = SHA3_512.new
hash_types['keccak_256'] = partial(keccak.new, digest_bits=256)
hash_types['keccak_512'] = partial(keccak.new, digest_bits=512)
return hash_types
评论列表
文章目录