量化交易——api签名加盐之md5加密

MD5加密

import hmac
import hashlib

ekey = 'samplekey'
to_enc = 'sampledata'
ekey = ekey.encode(encoding='UTF8')
to_enc = to_enc.encode(encoding='UTF8')
print(ekey)

enc_res = hmac.new(ekey, to_enc, digestmod=hashlib.md5).hexdigest()
enc_res1 = hmac.new(ekey, to_enc, digestmod=hashlib.md5).digest()
print(enc_res)
print(enc_res1)

输出如下

b'samplekey'
bda248a065e12684b497280b5515a81a
b'\xbd\xa2H\xa0e\xe1&\x84\xb4\x97(\x0bU\x15\xa8\x1a'

猜你喜欢

转载自blog.csdn.net/ruoruodetouzizhe/article/details/82879592
今日推荐