From b0a8b2b4f74b03272c64af66257c3503331674a9 Mon Sep 17 00:00:00 2001 From: Calvin Morrison Date: Tue, 16 Oct 2018 12:50:28 -0400 Subject: comment + spacing whatever --- totp.pl | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'totp.pl') 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 = ""; -- cgit v1.2.3