SESSION-TOKEN(1p)
β¨ 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::Tokensupports via the--alphabetswitch π its default alphabet is the (IMO) nice base-62, versusopenssl rand's base-64. - it can efficiently generate a large number of random tokens with the
--numswitch π₯ callingopenssl randfor each token would fork a lot of processes and open and read from/dev/urandomin each one. not it. - if cross-platform determinism is required, the
--seedor--null-seedswitches 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 randdoes some weirdness with reading from/writing to the~/.rndfile in your home directory as a potential entropy source/store πsession-tokenwill always fail noisily if it can't read from/dev/urandom.- and finally,
session-tokenis easier to remember and type β don't you think? π
π SEE ALSO π
- App-Session-Token github repo β
https://github.com/hoytech/App-Session-Token Session::Token
π AUTHOR π
Doug Hoyte, <doug@hcsw.org>
π COPYRIGHT & LICENSE π
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
- debian trixie: session-token 0.102-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: session-token 0.102-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu questing: session-token 0.102-2
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms