用于加密相關(guān)的操作,代替了md5模塊和sha模塊,主要提供SHA1,SHA224,SHA256,SHA512,MD5算法。
成都創(chuàng)新互聯(lián) - 服務(wù)器托管,四川服務(wù)器租用,成都服務(wù)器租用,四川網(wǎng)通托管,綿陽服務(wù)器托管,德陽服務(wù)器托管,遂寧服務(wù)器托管,綿陽服務(wù)器托管,四川云主機(jī),成都云主機(jī),西南云主機(jī),服務(wù)器托管,西南服務(wù)器托管,四川/成都大帶寬,成都機(jī)柜租用,四川老牌IDC服務(wù)商以下是算法示例:
#!/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())