summaryrefslogtreecommitdiffstats
path: root/sha1/test
diff options
context:
space:
mode:
Diffstat (limited to 'sha1/test')
-rwxr-xr-xsha1/test/totp.pl6
1 files changed, 5 insertions, 1 deletions
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;