From 9b5367618ae9d3fbae4b00264ab24dbaa03613b1 Mon Sep 17 00:00:00 2001 From: Your Name Date: Thu, 18 Jul 2019 12:13:17 +0100 Subject: debug improvements --- sha1/test/totp.pl | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'sha1/test') diff --git a/sha1/test/totp.pl b/sha1/test/totp.pl index 5903133..cd40aa0 100755 --- a/sha1/test/totp.pl +++ b/sha1/test/totp.pl @@ -171,7 +171,11 @@ sub generateCurrentNumber { my $offset = hex(substr($hmac, -1)); print "offset=",$offset,"\n"; # take the 4 bytes (8 hex chars) at the offset (* 2 for hex), and drop the high bit - my $encrypted = hex(substr($hmac, $offset * 2, 8)) & 0x7fffffff; + my $hex = substr($hmac, $offset * 2, 8); + my $encrypted = hex($hex) & 0x7fffffff; + + print "hex=",sprintf("%08x", $encrypted),"\n"; + # the token is then the last 6 digits in the number my $token = $encrypted % 1000000; -- cgit v1.2.3