Perl Authen :: OathとGoogle Authenticator-互換性がありませんか?
-
26-10-2019 - |
質問
私の理解(明らかに間違っているかもしれません)は authen ::誓い モジュールは、Google Authenticatorアプリによって生成されたTOTPコードと互換性があります。しかし、それは私にとってはうまくいきませんが、同様のRubyコードはそうです。私たちはここのPerl Shopであり、誰もが私を正しい方向に向けて、私を両方の図書館で掘り下げることを救うことができれば役立ちます。
この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
エンコードされていないパスワードが期待されます totp
と hotp
. 。それがオプションでない場合は、試すことができます decode_base32
から 変換:: base32
use Convert::Base32;
use Authen::OATH;
my $oath = Authen::OATH->new();
my $totp = $oath->totp( decode_base32( "bqagf6ohx4rp3a67" ) );
print "$totp\n";
所属していません StackOverflow