Encryption in nodejs

前端 未结 2 1298
死守一世寂寞
死守一世寂寞 2021-02-20 15:46

I\'m trying to port the following php code to javascript on node.js:

$mac = hash_hmac(\'SHA256\', \'string\', \'secret\', true);
$coded = base64_encode($mac);

2条回答
  •  闹比i
    闹比i (楼主)
    2021-02-20 16:28

    You want to use the createHmac function instead.

    Crypto.createHmac("SHA256", 'secret').update('string').digest('base64')
    

提交回复
热议问题