MD5的tohex,tobyte,tobase64用法示例(js与python)

1,525 阅读1分钟

CryptoJS原文

Python原文

Md5摘要,转为16进制字符串(Md5字节数组转String默认即是十六进制)

CryptoJS
CryptoJS.MD5(value).toString(CryptoJS.enc.HEX)
Python
hashlib.new('md5', b'str').hexdigest()

Md5摘要,直接将字节流转为Base64

CryptoJS
  • CryptoJS.MD5(value).toString(CryptoJS.enc.Base64)
    
  • CryptoJS.enc.Base64.stringify(CryptoJS.MD5(value))
    
Python
base64.b64encode(hashlib.new('md5', b'str').digest())

Md5摘要,转为Byte

CryptoJS

Python
hashlib.new('md5', b'str').digest()