【问题标题】:What is Ruby's OpenSSL::HMAC.new in JS?JS 中 Ruby 的 OpenSSL::HMAC.new 是什么?
【发布时间】:2018-05-30 23:27:27
【问题描述】:

我有一些用于 API 的示例代码,但它是用 Ruby 编写的,而我更喜欢使用 nodeJS。各位好心的 ruby​​/JS 小伙子能否告诉我 JS 等价物是什么,以及我需要安装的任何 npm 库。

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

【问题讨论】:

    标签: node.js ruby openssl


    【解决方案1】:

    试试这个

    var crypto = require('crypto');
    
    hmac = crypto.createHmac('SHA512', sharedsecret);
    hmac.update(url);
    signature = hmac.digest('hex');
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-03-31
      • 2015-04-25
      • 2021-12-25
      • 2020-02-28
      • 2011-03-04
      • 2013-08-14
      • 2023-04-01
      • 2010-09-14
      相关资源
      最近更新 更多