Perl Authen :: OATH and Google Authenticator - incompatible?

My understanding (which obviously could be wrong) is that the Authen :: OATH module is compatible with the Totp codes generated by the Google Authenticator application. But this does not work for me, whereas a similar bit of Ruby code. We are a perl store here, and it would help if someone could point me in the right direction to save me from digging through both libraries line by line.

This ruby โ€‹โ€‹works compatible:

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"; 
+6
source share
1 answer

This is not very clear from the documentation, but Authen::OATH expects unencoded passwords to be totp and hotp . If this is not an option, you can 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"; 
+5
source

Source: https://habr.com/ru/post/902767/


All Articles