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

标签 perl google-authenticator

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

这个 ruby​​ 兼容:

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 的未编码密码。如果这不是一个选项,您可以尝试 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 - 不兼容?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8330286/

相关文章:

perl - 避免系统 perl 函数中的代码注入(inject)

java - 读取 perl 脚本错误 : CreateProcess error=193, %1 不是有效的 Win32 应用程序

mysql - Perl DBI :mysql connection over SSL fails

python - PyOTP 生成的代码与 Google Authenticator 生成的代码不匹配

php - 如何在 PHP 中使用 Google Authenticator 生成唯一的二维码?

Perl:进行最长前缀匹配的最佳方法(字符串)

linux - 检查 fork 的 child 是否已经在 perl 中执行

android - 使用电子邮件和密码进行谷歌身份验证。

c# - 向用户添加 2fa 身份验证器