我的理解(显然是错误的)是 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 期望未编码的密码到 totphotp. 。如果不是一个选择,您可以尝试 decode_base32convert :: base32

use Convert::Base32;
use Authen::OATH;

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

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

print "$totp\n";
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top