1Authen::OATH(3) User Contributed Perl Documentation Authen::OATH(3)
2
3
4
6 Authen::OATH - OATH One Time Passwords
7
9 version 2.0.1
10
12 use Authen::OATH;
13
14 my $oath = Authen::OATH->new();
15 my $totp = $oath->totp( 'MySecretPassword' );
16 my $hotp = $oath->hotp( 'MyOtherSecretPassword' );
17
18 Parameters may be overridden when creating the new object:
19
20 my $oath = Authen::OATH->new( digits => 8 );
21
22 The three parameters are "digits", "digest", and "timestep." Timestep
23 only applies to the totp() function.
24
25 While strictly speaking this is outside the specifications of HOTP and
26 TOTP, you can specify digests other than SHA1. For example:
27
28 my $oath = Authen::OATH->new(
29 digits => 10,
30 digest => 'Digest::MD6',
31 );
32
33 If you are using Google Authenticator, you'll want to decode your
34 secret *before* passing it to the "totp" method:
35
36 use Convert::Base32 qw( decode_base32 );
37
38 my $oath = Authen::OATH->new;
39 my $secret = 'mySecret';
40 my $otp = $oath->totp( decode_base32( $secret ) );
41
43 Implementation of the HOTP and TOTP One Time Password algorithms as
44 defined by OATH (http://www.openauthentication.org)
45
46 All necessary parameters are set by default, though these can be
47 overridden. Both totp() and htop() have passed all of the test vectors
48 defined in the RFC documents for TOTP and HOTP.
49
50 totp() and hotp() both default to returning 6 digits and using SHA1.
51 As such, both can be called by passing only the secret key and a valid
52 OTP will be returned.
53
55 totp
56 my $otp = $oath->totp( $secret [, $manual_time ] );
57
58 Manual time is an optional parameter. If it is not passed, the current
59 time is used. This is useful for testing purposes.
60
61 hotp
62 my $opt = $oath->hotp( $secret, $counter );
63
64 Both parameters are required.
65
66 _process
67 This is an internal routine and is never called directly.
68
70 Please see the SYNOPSIS for how interaction with Google Authenticator.
71
73 Kurt Kincaid <kurt.kincaid@gmail.com>
74
76 This software is copyright (c) 2010-2017 by Kurt Kincaid.
77
78 This is free software; you can redistribute it and/or modify it under
79 the same terms as the Perl 5 programming language system itself.
80
81
82
83perl v5.28.0 2017-04-12 Authen::OATH(3)