summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCalvin Morrison <calvin@fastmailteam.com>2018-10-16 12:50:28 -0400
committerCalvin Morrison <calvin@fastmailteam.com>2018-10-16 12:50:28 -0400
commitb0a8b2b4f74b03272c64af66257c3503331674a9 (patch)
treee301d7d2db8fad6b071537e1bd6f205ecc226e39
parent2aa85f379bd8e18112bc27587022a0a2b79cbafb (diff)
comment + spacing whateverHEADmaster
-rw-r--r--totp.pl7
1 files changed, 3 insertions, 4 deletions
diff --git a/totp.pl b/totp.pl
index bfbda7d..fbc892b 100644
--- a/totp.pl
+++ b/totp.pl
@@ -16,14 +16,14 @@ sub hotp_truncate {
my $offset = (hex $lastbyte) & 0xf;
my $offset = $offset * 2;
- my $truncate = (
+ my $truncate = (
(hex substr($hex, $offset , 2) & 0x7f) << 24 |
(hex substr($hex, $offset + 2, 2) & 0xff) << 16 |
(hex substr($hex, $offset + 4, 2) & 0xff) << 8 |
(hex substr($hex, $offset + 6, 2) & 0xff)
);
- # 6 letter;
+ # 6 letter;
$truncate = substr($truncate, -6);
return $truncate;
@@ -49,14 +49,13 @@ sub hotp {
my $secret_hex = unpack "H*", decode_base32($secret);
my $time_hex= sprintf("%016s", sprintf("%x", $time));
-
# SHA-1 Hex your secret
my $hash = hmac_sha1_hex_string($time_hex, $secret_hex);
+ # run trunc to generate a user useable number
my $otp = hotp_truncate($hash);
return $otp;
-
}
my $secret = "";