Perl Authen::OATH 和 Google Authenticator - 不兼容?

Posted

技术标签:

【中文标题】Perl Authen::OATH 和 Google Authenticator - 不兼容?【英文标题】:Perl Authen::OATH and Google Authenticator - incompatible? 【发布时间】: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";

【问题讨论】:

【参考方案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";

【讨论】:

以上是关于Perl Authen::OATH 和 Google Authenticator - 不兼容?的主要内容,如果未能解决你的问题,请参考以下文章

JSON锛?JavaScript Object Notation

5.15心得

Perl 5 + Perl 6 = Perl 11

Perl 和 .NET RSA 一起工作?从 Perl 公钥在 .NET 中加密?从 Perl 加载私钥?

从另一个 Perl 脚本内部调用 Perl 搜索和替换命令时不起作用

perl语言