sodium11.py 文件源码

python
阅读 35 收藏 0 点赞 0 评论 0

项目:sodium11 作者: trbs 项目源码 文件源码
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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号