JS中的Ruby的OpenSSL :: HMAC.new是什么?

问题描述 投票:0回答:1

我有一些API的示例代码,但它在Ruby中,而我更喜欢使用nodeJS。你能不能使用任何类型的ruby / JS chaps让我知道JS的等价物,以及我需要安装的任何npm库。

 hmac = OpenSSL::HMAC.new(sharedsecret, OpenSSL::Digest::SHA512.new)
 signature = hmac.update(url)
node.js ruby openssl
1个回答
0
投票

试试这个吧

var crypto = require('crypto');

hmac = crypto.createHmac('SHA512', sharedsecret);
hmac.update(url);
signature = hmac.digest('hex');
© www.soinside.com 2019 - 2024. All rights reserved.