Perl Authen ::誓言和Google Authenticator-不兼容?
-
26-10-2019 - |
题
我的理解(显然是错误的)是 Authen ::宣誓 模块与Google Authenticator应用程序生成的TOTP代码兼容。但这对我不起作用,而类似的红宝石代码也是如此。我们是这里的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";
解决方案
从文档中不太清楚,但是 Authen::OATH
期望未编码的密码到 totp
和 hotp
. 。如果不是一个选择,您可以尝试 decode_base32
从 convert :: base32
use Convert::Base32;
use Authen::OATH;
my $oath = Authen::OATH->new();
my $totp = $oath->totp( decode_base32( "bqagf6ohx4rp3a67" ) );
print "$totp\n";
不隶属于 StackOverflow