Skip to content

Commit

Permalink
Merge pull request #13 from gmihaly-lmi/master
Browse files Browse the repository at this point in the history
Fix for secrets where we have odd number of hex digits. For example Amazon.com totp secrets.
  • Loading branch information
jiangts committed Feb 8, 2021
2 parents 8cfc5df + 2ef9c7d commit 2d7ea54
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion coffee/jsOTP.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@ class Totp
bits += @leftpad(val.toString(2), 5, "0")
i++

checklength = bits.length - bits.length % 8
i = 0
while i + 4 <= bits.length
while i + 4 <= checklength
chunk = bits.substr(i, 4)
hex = hex + parseInt(chunk, 2).toString(16)
i += 4
Expand Down

0 comments on commit 2d7ea54

Please sign in to comment.