大橙子网站建设,新征程启航
为企业提供网站建设、域名注册、服务器等服务
用于加密相关的操作,代替了md5模块和sha模块,主要提供SHA1,SHA224,SHA256,SHA512,MD5算法。
成都创新互联 - 服务器托管,四川服务器租用,成都服务器租用,四川网通托管,绵阳服务器托管,德阳服务器托管,遂宁服务器托管,绵阳服务器托管,四川云主机,成都云主机,西南云主机,服务器托管,西南服务器托管,四川/成都大带宽,成都机柜租用,四川老牌IDC服务商以下是算法示例:
#!/usr/bin/env python # -*- coding:utf-8 -*- import hashlib #=================MD5()加密===================== hhb = hashlib.md5(bytes("jahiuhfdakj", encoding='utf-8')) #加盐处理 ret = hhb.update(bytes("123", encoding='utf-8')) #“123”是需要加密的字符串 print("MD5加密:", hhb.hexdigest()) #=================SHA1()加密===================== hhb = hashlib.sha1() ret = hhb.update(bytes("123", encoding='utf-8')) print("SHA1加密:", hhb.hexdigest()) #=================SHA224()加密===================== hhb = hashlib.sha224() ret = hhb.update(bytes("123", encoding='utf-8')) print("SHA224加密:", hhb.hexdigest()) #=================SHA256()加密===================== hhb = hashlib.sha256() ret = hhb.update(bytes("123", encoding='utf-8')) print("SHA256加密:", hhb.hexdigest()) #=================SHA512()加密===================== hhb = hashlib.sha512() ret = hhb.update(bytes("123", encoding='utf-8')) print("SHA512加密:", hhb.hexdigest()) #=================SHA3_256()加密===================== hhb = hashlib.sha3_256() ret = hhb.update(bytes("123", encoding='utf-8')) print("SHA3_256加密:", hhb.hexdigest()) #=================SHA3_384()加密===================== hhb = hashlib.sha3_384() ret = hhb.update(bytes("123", encoding='utf-8')) print("SHA3_384加密:", hhb.hexdigest()) #=================SHA3_512()加密===================== hhb = hashlib.sha3_512() ret = hhb.update(bytes("123", encoding='utf-8')) print("SHA3_512加密:", hhb.hexdigest())