Crypt:...::Token(3pm)

πŸ“¦
version 0.005 Β· 3 versions
, in debian trixie, ubuntu resolute, ubuntu stonking

πŸ’– 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 $length isn't provided, it defaults to 44.
  • if $alphabet isn'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