Crypt:...::Token(3pm)
π Crypt::URandom::Token π
okay bestie, so this is the manual page for Crypt::URandom::Token, straight out of the User Contributed Perl Documentation, and it's literally the glow-up your secret-generating era needs. it makes secure strings for passwords, secrets, and similar β¨
πΈ NAME πΈ
Crypt::URandom::Token β generate secure strings for passwords, secrets and similar π
like, it does exactly what it says on the tin, no cap.
π¦ SYNOPSIS π¦
use Crypt::URandom::Token qw(urandom_token);
# generates a 44-character alphanumeric token (default)
my $token = urandom_token();
# generate a 19 character lowercase alphanumeric password
my $password = urandom_token(19, [a..z, 0..9]);
# generate a 6 digit numeric pin
my $pin = urandom_token(6, "0123456789");
# Object usage:
my $obj = Crypt::URandom::Token->new(
length => 44,
alphabet => [ A..Z, a..z, 0..9 ],
);
my $token = $obj->get;
see how easy that was?? one line and boom, token. the object way is giving main character energy too if you're into that π«Ά
π DESCRIPTION π
this module gives you a secure way to generate a random token for passwords and similar, and it pulls its random bits from Crypt::URandom. that's the source of random bits, periodt.
by default it generates a 44 character alphanumeric token with more than 256 bits of entropy. lowkey iconic. you can also hand it a custom alphabet with between 2 and 256 elements.
it uses modulo reduction and rejection sampling to prevent modulus bias β very demure, very mindful. but heads up bestie: bias will be introduced if you provide duplicate elements in the alphabet. so like, don't do that π
β¨ FUNCTIONS β¨
π urandom_token
my $token = urandom_token($length, $alphabet);
returns a string of $length random characters pulled from $alphabet. that's it, that's the whole vibe.
- if
$lengthisn't provided, it defaults to 44. - if
$alphabetisn't provided, it defaults to uppercase letters, lowercase letters, and digits. you can pass either a string of characters or an arrayref β dealer's choice π
π METHODS π
π new
creates a brand new token generator object. it accepts a hash or hashref with these parameters:
lengthβ desired token length (defaults to 44)alphabetβ the set of characters to use. can be a string of characters or an array reference. defaults to[ A..Z, a..z, 0..9 ]
β get
generates and returns a random token as a token, using the object attributes for length and alphabet. it's giving "set it and forget it" honestly.
π§ AUTHOR π§
Stig Palmquist <stig@stig.io> β shoutout to the legend who built this π
π LICENSE π
this library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
fr fr, that's the whole page. now go generate something cute and cryptographically sound π
and that's a wrap bestie π«Ά this was perl v5.40.1, dated 2025-05-23, for Crypt:...::Token(3pm) β stay random, stay secure, mwah ππ
π¦ where this page comes from
- debian trixie: libcrypt-urandom-token-perl 0.005-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libcrypt-urandom-token-perl 0.005-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libcrypt-urandom-token-perl 0.005-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms