SESSION-TOKEN(1p)

πŸ“¦
version 0.102 Β· 2 versions
, in debian trixie, ubuntu noble, ubuntu questing

✨ NAME ✨

okay so bestie, this is session-token β€” the command-line script for generating session tokens πŸ’–


πŸŽ€ USAGE πŸŽ€

like, here's the vibe:

$ session-token
ATXOpAxCu57sVZvoBiWgHg

$ session-token --entropy 256
hk0No9bjuknBxmpIujW3bZvnFmryTvEbTPNitd8L9kC

$ session-token --length 5 --alphabet ACGT --num 3
GAATT
ACCAT
AATTG

## If you don't know how many tokens you need at the start of the pipeline...
$ session-token --infinity | ... | head

🌸 DESCRIPTION 🌸

ngl this module exists because the author kept catching themselves running this literally all the time:

$ perl -MSession::Token -E 'say Session::Token->new->get'
YwXYXGLMMnudk33MbClseQ

and before Session::Token was even a thing, the move was this:

$ openssl rand -base64 16
fjxhL/LmZEUQ+NCldQbHgA==

both of them do essentially the same task, BUT session-token has ✨various advantages✨:

  • it's way more flexible about the alphabet you use, since it supports any alphabet that Session::Token supports via the --alphabet switch πŸ’… its default alphabet is the (IMO) nice base-62, versus openssl rand's base-64.
  • it can efficiently generate a large number of random tokens with the --num switch πŸ”₯ calling openssl rand for each token would fork a lot of processes and open and read from /dev/urandom in each one. not it.
  • if cross-platform determinism is required, the --seed or --null-seed switches are available and they don't require seed files or anything 🫢
⚠️ but bestie listen β€” you should only use these switches for benchmarks or simulations, and never for applications requiring secure randomness, because the generated sequence of tokens will be the same for each run. same token every time = not it for secrets πŸ’€
  • openssl rand does some weirdness with reading from/writing to the ~/.rnd file in your home directory as a potential entropy source/store πŸ™ˆ session-token will always fail noisily if it can't read from /dev/urandom.
  • and finally, session-token is easier to remember and type β€” don't you think? πŸ‘‘

πŸ‘€ SEE ALSO πŸ‘€


πŸ’œ AUTHOR πŸ’œ

Doug Hoyte, <doug@hcsw.org>


Copyright 2014-2016 Doug Hoyte.

This module is licensed under the same terms as perl itself.


and that's a wrap, bestie πŸ¦‹ this was SESSION-TOKEN(1p), brought to you by perl v5.36.0 and dated 2023-12-15 πŸ’– slay, go make some tokens ✨

πŸ“¦ where this page comes from