【发布时间】:2025-11-23 02:50:01
【问题描述】:
当我请求一个函数来生成签名但签名哈希它仍然是时,时间戳和设备 ID 总是会改变
ea6b458e9a840b7f93236244bf1ea7cb564a8f08
这个哈希生成代码
let array = [login_type, device_id, timestamp];
let hash = crypto.createHmac('sha1', secret_key).update(implode(array, "|")).digest('hex');
function timeMil(){
var date = new Date();
var timeMil = date.getTime();
return timeMil;
}
const device_id = "2752707c1c745ff8";
const secret_key = "9LXAVCxcITaABNK48pAVgc4muuTNJ4enIKS5YzKyGZ";
const timestamp = timeMil();
let array = [login_type, device_id, timestamp];
let hash = crypto.createHmac('sha1', secret_key).update(implode(array, "|")).digest('hex');
console.log(hash);
生成的 hash_hmac 总是 ea6b458e9a840b7f93236244bf1ea7cb564a8f08
【问题讨论】:
标签: javascript node.js sha1 hmacsha1