最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

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

运维笔记admin14浏览0评论

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

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

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

 hmac = OpenSSL::HMAC.new(sharedsecret, OpenSSL::Digest::SHA512.new)
 signature = hmac.update(url)
回答如下:

试试这个吧

var crypto = require('crypto');

hmac = crypto.createHmac('SHA512', sharedsecret);
hmac.update(url);
signature = hmac.digest('hex');
发布评论

评论列表(0)

  1. 暂无评论