A-A+
python HMAC CryptoJS hmac = CryptoJS.HmacRIPEMD160(message, key)

【注意:此文章为博主原创文章!转载需注意,请带原文链接,至少也要是txt格式!】
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | import hmac import base64 import hashlib import time import sys data = sys.argv[1] key = str(int(round((time.time()) * 1000))) print(key) # data = base64.b64encode(data) # key = base64.b64encode(key) data = hmac.new(key.encode(), data.encode(), digestmod=hashlib.sha256) # print(data) # data = base64.b64encode(data) msg = data.digest() # print(msg) print(base64.b64encode(msg)) |
webpack:///./node_modules/crypto-js/ripemd160.js
部分调用处JS代码:
1 2 3 4 5 6 7 8 9 10 11 12 | function M(e, t) {
var n = (new Date).getTime() + t
, i = l.a.stringify(r()(e, n.toString()))
, a = sessionStorage.accessToken ? sessionStorage.accessToken : null;
return {
"X-timevale-project-id": sessionStorage.projectId,
requestTimeStamp: n,
token: i,
Authorization: "bearer " + a,
"Accept-Language": N(window.location.href, "lang") || "zh_CN"
}
} |
HMAC 部分代码:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | /**
* Shortcut function to the hasher's object interface.
*
* @param {WordArray|string} message The message to hash.
*
* @return {WordArray} The hash.
*
* @static
*
* @example
*
* var hash = CryptoJS.RIPEMD160('message');
* var hash = CryptoJS.RIPEMD160(wordArray);
*/
C.RIPEMD160 = Hasher._createHelper(RIPEMD160);
/**
* Shortcut function to the HMAC's object interface.
*
* @param {WordArray|string} message The message to hash.
* @param {WordArray|string} key The secret key.
*
* @return {WordArray} The HMAC.
*
* @static
*
* @example
*
* var hmac = CryptoJS.HmacRIPEMD160(message, key);
*/
C.HmacRIPEMD160 = Hasher._createHmacHelper(RIPEMD160);
}(Math));
return CryptoJS.RIPEMD160; |
布施恩德可便相知重
微信扫一扫打赏
支付宝扫一扫打赏