Perl Authen::OATH and Google Authenticator - incompatible?

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";

Answers


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";

Need Your Help

PHP Register not working correctly

php sql

I have an error with a PHP register page I am creating.

Mercurial - How to pull all revisions on all branches up to a specific point?

mercurial branch pull revision

I guess I must have misunderstood the author of this post when he said:

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.