代码拉取完成,页面将自动刷新
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Date : 2016-11-11 16:38:36
# @Author : PiaoYun (piaoyunsoft@163.com)
# @Link : http://www.dllhook.com
# @Version : $Id$
import hmac
import hashlib
from Crypto.Hash import HMAC
from Crypto.Hash import MD2
from Crypto.Hash import MD4
from Crypto.Hash import MD5
from Crypto.Hash import RIPEMD
from Crypto.Hash import SHA
from Crypto.Hash import SHA224
from Crypto.Hash import SHA256
from Crypto.Hash import SHA384
from Crypto.Hash import SHA512
message = b"www.chinapyg.com"
def defaultHMAC():
h = hmac.new(b'piaoyun')
h.update(message)
print h.hexdigest().upper()
def pyCryptoHMAC():
secret = b'piaoyun'
h = HMAC.new(secret)
h.update(message)
print h.hexdigest().upper()
def _MD(type):
h = None
if type == 2:
h = MD2.new()
elif type == 4:
h = MD4.new()
elif type == 5:
h = MD5.new()
h.update(message)
print h.hexdigest().upper()
def _RIPEMD():
h = RIPEMD.new()
h.update(message)
print h.hexdigest().upper()
def _SHA(type):
h = None
if type == 1:
h = SHA.new()
elif type == 224:
h = SHA256.new()
elif type == 256:
h = SHA256.new()
elif type == 384:
h = SHA384.new()
elif type == 512:
h = SHA512.new()
h.update(message)
print h.hexdigest().upper()
if __name__ == '__main__':
print("====HMAC Test====")
defaultHMAC()
pyCryptoHMAC()
print("====MD Test====")
_MD(2)
_MD(4)
_MD(5)
print("====RIPEMD Test====")
_RIPEMD()
print("====SHA Test====")
_SHA(1)
_SHA(224)
_SHA(256)
_SHA(384)
_SHA(512)
print("====hashlib Test====")
h = hashlib.md5()
h.update(message)
print h.hexdigest().upper()
print h.digest().encode('hex').upper()
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。