使用 HMAC 方法生成帶有密鑰的哈希值
hash_hmac ( string $algo , string $data , string $key [, bool $raw_output = false ] )
參數
¶
algo
data
要進行哈希運算的消息。
key
使用 HMAC 生成信息摘要時所使用的
密鑰
。
raw_output
設置為 TRUE
輸出原始
二進制
數據, 設置為 FALSE
輸出小寫 16 進制字符串。
python的
import hashlib
import hmac
hmac.
new
(
key
,
msg=None
,
digestmod=None
)
第一個參數:秘鑰
2:數據
3:算法
hashlib.sha256,
hashlib.sha1
digest對應php的raw_output=TRUE
import base64
base64.b64encode(s)
base64.b64decode(aa)