My understanding (which may obviously be wrong) is that the Authen::OATH module is compatible with the totp codes generated by the Google Authenticator App. But it doesn't work for me, whereas a similar bit of ruby code does. We're a perl shop here and it would help if anyone could point me in the right direction to save me from digging through both libraries line by line.
This ruby works compatibly:
require 'rubygems'
require 'rotp'
secret = "bqagf6ohx4rp3a67"
puts ROTP::TOTP.new(secret).now.to_s
This perl does not:
use Authen::OATH;
my $oath = Authen::OATH->new();
my $totp = $oath->totp(" bqagf6ohx4rp3a67" );
print "$totp\n";
It's not very clear from the documentation, but Authen::OATH
expects the unencoded passwords to totp
and hotp
. If that's not an option, you could try decode_base32
from Convert::Base32
use Convert::Base32;
use Authen::OATH;
my $oath = Authen::OATH->new();
my $totp = $oath->totp( decode_base32( "bqagf6ohx4rp3a67" ) );
print "$totp\n";
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With