Created
January 22, 2012 16:49
-
-
Save ritou/1657640 to your computer and use it in GitHub Desktop.
Authen::OATH Demo Code
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $ cat Authen_OATH_sample.pl | |
| #!/usr/bin/env perl | |
| use strict; | |
| use warnings; | |
| use Authen::OATH; | |
| use MIME::Base32 qw( RFC ); | |
| my $oath = Authen::OATH->new(); | |
| my $secret = "1234567890"; | |
| my $counter = "1"; | |
| my $key = MIME::Base32::encode( $secret ); | |
| my $totp = $oath->totp( $secret ); | |
| my $hotp = $oath->hotp( $secret, $counter ); | |
| # output | |
| print "===== OATH OTP Demo =====\n"; | |
| print "secret : $secret\n"; | |
| print "key(Base32 encoded secret) : $key\n"; | |
| print "\n"; | |
| print "===== HOTP =====\n"; | |
| print "counter : $counter\n"; | |
| print "hotp : $hotp\n"; | |
| print "\n"; | |
| print "===== TOTP =====\n"; | |
| print "totp : $totp\n"; | |
| print "\n"; | |
| $ perl Authen_OATH_issue_TOTP.pl | |
| ===== OATH OTP Demo ===== | |
| secret : 1234567890 | |
| key(Base32 encoded secret) : GEZDGNBVGY3TQOJQ | |
| ===== HOTP ===== | |
| counter : 1 | |
| hotp : 263420 | |
| ===== TOTP ===== | |
| totp : 636562 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment