【发布时间】:2018-09-03 10:45:24
【问题描述】:
最近我在 PHP 上使用了相同的代码,它运行良好,但是当我尝试 Node Js 时,它不适合我。请检查一次:
PHP
$signature = $ACCID . "POST" . strtolower(urlencode($url)).$requestContentBase64String;
$hmacsignature = base64_encode(hash_hmac("sha256", $signature, base64_decode($APIKey), true));
节点代码:
var signature = ACCID+"POST"+encodeURI(url).toLowerCase()+requestContentBase64String;
var hmacsignature = base64.encode(crypto.createHmac('sha256', APIKey).update(signature).digest('base64'))
请检查这段代码有什么问题。
【问题讨论】: