【问题标题】:Mobile verification in android app using speakeasy as npm module for generating otp?android 应用程序中的移动验证使用 speakeasy 作为 npm 模块生成 otp?
【发布时间】:2015-12-27 19:45:26
【问题描述】:

大家好,我正在使用 Speakeasy npm 模块在一个时间范围内生成 totp 现在下面是我的工作流程,谁能告诉我我是否遗漏了什么。当用户注册时,我会在请求中获取其手机号码,然后将其用作秘密并生成我的 totp,以便每个用户的 totp 可以是唯一的

var mobile_no = req.body.mobile_no;
speakeasy.totp({key: mobile_no, step: 60})

我通过我的用户的手机号码发送它然后将它发送到服务器以在服务器上检查现在我正在从 totp 模块再次检查它

var mobile_no = req.body.mobile_no;
var sent_totp = req.body.totp;
if (sent_totp == speakeasy.totp({key: mobile_no, step: 60})) {
console.log('Registration successfull');
} else {
console.log('OTP does not match');
}

如果匹配,那么我进行注册,否则现在不是我做的一切是否正确?请告诉我,我的方法有问题吗

【问题讨论】:

  • 您的问题已经解决或仍未解决???
  • 我正在使用相同的方法,我不知道它是否正确?你有什么想法吗??
  • 我在发送 otp 和验证 otp 时为每个用户保密。
  • 注册后为每个用户生成一个唯一的秘密。之后使用该秘密生成并验证 OTP。这是我的建议。
  • 确保密钥或秘密是字符串类型。

标签: android node.js one-time-password


【解决方案1】:

 var code = speakeasy.totp({key: 'abc123'});
    users.get(data.phone_number, function (geterr, doc,         key) {
      if (geterr) {
        createUser(data.phone_number, code, socket);
      }
      else if (checkVerified(socket, doc.verified, data.phone_number) == false) {
        socket.emit('update', {message: "Your message goes in here"});
        socket.emit('code_generated'); //if code have been generated
      }
    });

//希望对你有帮助

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-09-23
    • 2020-03-21
    • 2016-05-27
    • 2018-08-22
    • 2011-02-11
    • 1970-01-01
    • 2021-10-03
    相关资源
    最近更新 更多