Time-based one-time password algorithm: Difference between revisions

m
→‎{{header|Perl 6}}: fix incorrect substr offset ; update output
(added Perl 6)
m (→‎{{header|Perl 6}}: fix incorrect substr offset ; update output)
Line 320:
sub totp (Str \secret, DateTime \counter, Int \T0=0, Int \T1=30 --> Str) {
my \key = ( counter - DateTime.new(T0) ).Int div T1;
return hmac-hex(key.Str, secret, &sha1).substr(0,56) # first 6 chars of sha1
}
 
Line 337:
{{out}}
<pre>Deterministic output at 2039-01-01T00:00:00Z with fixed checks,
34ca2a
34ca2
acfa3f
acfa3
950fc3
950fc
950fc3
950fc
a2d4ea
a2d4e
a2d4ea
a2d4e
Current time output at 2019-03-31T1331T15:1400:1901.635127Z765312Z with random checks,
4e36de
9e6f3
d4e9f8
2b5bc
d4e9f8
2b5bc
077e2c
836ce
63bbb5
95955
a79e163bbb5</pre>
 
=={{header|PicoLisp}}==
350

edits