[removed] Equivalent of PHP's hash_hmac() with RAW BINARY output?

前端 未结 5 1608
轮回少年
轮回少年 2021-02-05 13:12

I am connecting to the Amazon Product Advertising API, and to sign my request I need to base64-encode the raw binary output of an HMAC-SHA256 hash.

In t

5条回答
  •  攒了一身酷
    2021-02-05 13:57

    This worked for me :

    var CryptoJS = require("crypto-js");
    const raw_signature = hmacSHA1(baseString, signingKey);
    const signature = raw_signature.toString(CryptoJS.enc.Base64);
    

    It's giving the exact same result as, in PHP, :

    $rawSignature = hash_hmac("sha1", $baseString, $signingKey, true);
    $signature    = base64_encode($rawSignature);
    

提交回复
热议问题