Pass::OTP(3pm)

πŸ“¦
version 1.901 Β· 4 versions
, in ubuntu stonking

πŸ’– Pass::OTP πŸ’–

okay bestie so this is Pass::OTP, from the User Contributed Perl Documentation corner of the Pass::OTP(3pm) manual β€” she's a Perl implementation of HOTP / TOTP algorithms and she is literally carrying your entire two-factor auth life on her back. no cap. 🫢


✨ NAME ✨

Pass::OTP β€” the girl who does HOTP / TOTP algorithms in pure Perl and never once complains about it. πŸ’…


πŸŽ€ SYNOPSIS πŸŽ€

like, this is the whole vibe in four lines:

use Pass::OTP qw(otp);
use Pass::OTP::URI qw(parse);

my $uri = "otpauth://totp/ACME:john.doe@email.com?secret=HXDMVJECJJWSRB3HWIZR4IFUGFTMXBOZ&issuer=ACME&digits=6";
my $otp_code = otp(parse($uri));

see how she ate that? you hand her a otpauth:// URI, she hands you a code. iconic behaviour honestly. ✨


🌸 DESCRIPTION 🌸

Pass::OTP is a module that provides the implementation of HOTP and TOTP algorithms according to RFC 4226 and RFC 6238. that's it. that's the whole personality. and honestly? she doesn't need to be anything else. πŸ”₯


πŸ¦‹ FUNCTIONS πŸ¦‹

hotp(%options)

computes HMAC-based One-time Password (RFC 4226). here's the math, bestie, she's showing her work because she's a straight-A student:

HOTP(K,C) = Truncate(HMAC-SHA-1(K,C))

Step 1: Generate an HMAC-SHA-1 value

Let HS = HMAC-SHA-1(K,C)

Step 2: Generate a 4-byte string (Dynamic Truncation)

Let Sbits = DT(HS)

Step 3: Compute an HOTP value

Let Snum = StToNum(Sbits)       # Convert S to a number in 0..2^{31}-1
Return D = Snum mod 10^Digit    # D us a number in the range 0..10^{Digit}-1

(quick heads up: yes, that comment says "D us a number" β€” that's the original's typo, not mine, she's keeping it exactly as written, we don't edit the source material in this house. πŸ’€πŸ™ˆ)

totp(%options)

computes Time-based One-time Password (RFC 6238). same energy, but the counter is time now:

TOTP = HOTP(K,T)
T = (Current Unix time - T0) / X

clock's ticking, bestie. ⏰

otp(%options)

the convenience wrapper ✨ β€” she just calls totp/hotp according to options so you don't have to pick. lowkey the nicest thing about her. she reads your options and routes you to the right queen. πŸ‘‘


πŸ” SEE ALSO πŸ”

go read these if you want the lore. she's not gatekeeping. 🌈


Copyright (C) 2020 Jan Baier

This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.

See <http://dev.perl.org/licenses/> for more information.

fr fr β€” she's free software, share her responsibly, and read the licenses before you go doing main character things with her. πŸ’–

omg and that's the page!! she's running on perl v5.40.1 and this whole slay was documented on 2026-06-12 β€” sending you off with the manual name one more time: Pass::OTP(3pm). go generate some one-time passwords, bestie, you've got this πŸ’…βœ¨πŸ«Ά

πŸ“¦ where this page comes from