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

Content deleted Content added
Hkdtam (talk | contribs)
added Perl 6
Hkdtam (talk | contribs)
m →‎{{header|Perl 6}}: fix incorrect substr offset ; update output
Line 320: Line 320:
sub totp (Str \secret, DateTime \counter, Int \T0=0, Int \T1=30 --> Str) {
sub totp (Str \secret, DateTime \counter, Int \T0=0, Int \T1=30 --> Str) {
my \key = ( counter - DateTime.new(T0) ).Int div T1;
my \key = ( counter - DateTime.new(T0) ).Int div T1;
return hmac-hex(key.Str, secret, &sha1).substr(0,5) # first 6 chars of sha1
return hmac-hex(key.Str, secret, &sha1).substr(0,6) # first 6 chars of sha1
}
}


Line 337: Line 337:
{{out}}
{{out}}
<pre>Deterministic output at 2039-01-01T00:00:00Z with fixed checks,
<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-31T13:14:19.635127Z with random checks,
Current time output at 2019-03-31T15:00:01.765312Z with random checks,
4e36de
9e6f3
d4e9f8
2b5bc
d4e9f8
2b5bc
077e2c
836ce
63bbb5
95955
a79e1</pre>
63bbb5</pre>


=={{header|PicoLisp}}==
=={{header|PicoLisp}}==