2

我必须以以下方式创建 HMAC_SHA1 哈希:

auth_reponse = HMAC_SHA1(key=session_id, data=decypted_challenge)

我怎么能用 M2Crypto 做到这一点?

4

1 回答 1

3

尝试:

from M2Crypto.EVP import HMAC
import base64

hmac = HMAC(session_id,'sha1')
hmac.update(decypted_challenge)

auth_response = base64.encodestring(hmac.digest()) #Base64 format

或者:

auth_response = hmac.digest() #Binary format

问候!

于 2012-09-10T02:59:53.167 回答