【问题标题】:Perl Authen::OATH and Google Authenticator - incompatible?Perl Authen::OATH 和 Google Authenticator - 不兼容?
【发布时间】:2012-01-09 22:41:06
【问题描述】:

我的理解(这可能显然是错误的)是Authen::OATH 模块与谷歌身份验证器应用程序生成的totp 代码兼容。但这对我不起作用,而类似的 ruby​​ 代码却可以。我们是这里的 perl 商店,如果有人能指出正确的方向,让我免于逐行挖掘这两个库,那将会有所帮助。

此红宝石兼容:

require 'rubygems'

require 'rotp'

secret = "bqagf6ohx4rp3a67"

puts ROTP::TOTP.new(secret).now.to_s

这个 perl 没有:

use Authen::OATH;

my $oath = Authen::OATH->new();

my $totp = $oath->totp(" bqagf6ohx4rp3a67" );

print "$totp\n";

【问题讨论】:

    标签: perl google-authenticator


    【解决方案1】:

    从文档中不是很清楚,但Authen::OATH 期望未编码的密码为totphotp。如果这不是一个选项,您可以从Convert::Base32 尝试decode_base32

    use Convert::Base32;
    use Authen::OATH;
    
    my $oath = Authen::OATH->new();
    
    my $totp = $oath->totp( decode_base32( "bqagf6ohx4rp3a67" ) );
    
    print "$totp\n";
    

    【讨论】:

      猜你喜欢
      • 2016-09-07
      • 1970-01-01
      • 1970-01-01
      • 2021-09-29
      • 1970-01-01
      • 2014-10-19
      • 1970-01-01
      • 1970-01-01
      • 2014-03-12
      相关资源
      最近更新 更多