Anonymous user
Time-based one-time password algorithm: Difference between revisions
Time-based one-time password algorithm (view source)
Revision as of 14:23, 14 February 2021
, 3 years ago→{{header|Tcl}}: -- Fix code so that padding of leading and ending zeros is correct
Thundergnat (talk | contribs) m (Thundergnat moved page Time-based One-time Password Algorithm to Time-based one-time password algorithm: Follow normal task title capitalization policy) |
(→{{header|Tcl}}: -- Fix code so that padding of leading and ending zeros is correct) |
||
Line 669:
namespace eval ::totp {
package require sha1
oo::class create totp {
variable Secret
Line 698:
hotp $Secret $bytes
}
}
proc hotp {secret bytes {length 6}} {
set hmac [sha1::hmac -bin $secret $bytes]
set ofs [string index $hmac end]
Line 708:
set chunk [string range $hmac $ofs $ofs+4]
binary scan $chunk I code
return [format %0${length}.${length}d [expr {($code & 0x7fffffff) %
}▼
▲ }
namespace export *
}
|