{"id":21651648,"url":"https://github.com/hoytech/app-session-token","last_synced_at":"2025-03-20T03:59:51.177Z","repository":{"id":17045106,"uuid":"19809493","full_name":"hoytech/App-Session-Token","owner":"hoytech","description":"Command line interface to Session::Token","archived":false,"fork":false,"pushed_at":"2016-09-22T14:16:10.000Z","size":6,"stargazers_count":2,"open_issues_count":1,"forks_count":1,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-01-25T05:42:46.160Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Perl","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hoytech.png","metadata":{"files":{"readme":"README.pod","changelog":"Changes","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-05-15T06:53:41.000Z","updated_at":"2024-06-27T01:48:30.000Z","dependencies_parsed_at":"2022-07-26T12:02:14.006Z","dependency_job_id":null,"html_url":"https://github.com/hoytech/App-Session-Token","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hoytech%2FApp-Session-Token","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hoytech%2FApp-Session-Token/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hoytech%2FApp-Session-Token/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hoytech%2FApp-Session-Token/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hoytech","download_url":"https://codeload.github.com/hoytech/App-Session-Token/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244547602,"owners_count":20470103,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-25T07:49:08.037Z","updated_at":"2025-03-20T03:59:51.156Z","avatar_url":"https://github.com/hoytech.png","language":"Perl","funding_links":[],"categories":[],"sub_categories":[],"readme":"#!/usr/bin/env perl\n\nuse strict;\n\nuse Session::Token;\nuse Getopt::Long;\n\nmy @opt_spec = (\n  ## Used by Session::Token constructor\n\n  'alphabet=s',\n  'entropy=i',\n  'length=i',\n  'seed=s',\n  \n  ## Special\n\n  'num|n=i',\n  'infinity',\n  'help|h|?',\n  'null-seed',\n);\n\nmy $opt = {};\n\nGetOptions($opt, @opt_spec) || die \"GetOptions failed\";\n\n\nif ($opt-\u003e{help}) {\n  require Pod::Perldoc;\n  @ARGV = ('-F', $0);\n  Pod::Perldoc-\u003erun();\n}\n\n\n$opt-\u003e{seed} = \"\\x00\"x1024 if $opt-\u003e{'null-seed'};\n\nmy $generator = Session::Token-\u003enew(%$opt);\n\n\nif (exists $opt-\u003e{num} \u0026\u0026 exists $opt-\u003e{infinity}) {\n  die \"can't specify both num and infinity\"\n} elsif (exists $opt-\u003e{infinity}) {\n  while(1) {\n    print $generator-\u003eget(), \"\\n\";\n  }\n} else {\n  my $iters = $opt-\u003e{num};\n\n  $iters = 1 if !defined $iters;\n\n  for (1 .. $iters) {\n    print $generator-\u003eget(), \"\\n\";\n  }\n}\n\n\n__END__\n\n=encoding utf-8\n\n=head1 NAME\n\nsession-token - command-line script for generating session tokens\n\n=head1 USAGE\n\n    $ session-token\n    ATXOpAxCu57sVZvoBiWgHg\n\n    $ session-token --entropy 256\n    hk0No9bjuknBxmpIujW3bZvnFmryTvEbTPNitd8L9kC\n\n    $ session-token --length 5 --alphabet ACGT --num 3\n    GAATT\n    ACCAT\n    AATTG\n\n    ## If you don't know how many tokens you need at the start of the pipeline...\n    $ session-token --infinity | ... | head\n\n\n=head1 DESCRIPTION\n\nThis module came about because I found myself frequently running the following command:\n\n    $ perl -MSession::Token -E 'say Session::Token-\u003enew-\u003eget'\n    YwXYXGLMMnudk33MbClseQ\n\nBefore I wrote L\u003cSession::Token\u003e I used to run the following command:\n\n    $ openssl rand -base64 16\n    fjxhL/LmZEUQ+NCldQbHgA==\n\nThey both perform essentially the same task however C\u003csession-token\u003e has various advantages:\n\nIt is more flexible regarding the alphabet used since it supports any alphabet that L\u003cSession::Token\u003e does via the C\u003c--alphabet\u003e switch. Its default alphabet is the (IMO) nice base-62 versus C\u003copenssl rand\u003e's base-64.\n\nIt can efficiently generate a large number of random tokens with the C\u003c--num\u003e switch. Calling C\u003copenssl rand\u003e for each token would fork a lot of processes and open and read from C\u003c/dev/urandom\u003e in each one.\n\nIf cross-platform determinism is required, the C\u003c--seed\u003e or C\u003c--null-seed\u003e switches are available and they don't require seed files or anything. Note that you should only use these switches for benchmarks or simulations and never for applications requiring secure randomness since the generated sequence of tokens will be the same for each run.\n\nC\u003copenssl rand\u003e does some weirdness with reading from/writing to the C\u003c~/.rnd\u003e file in your home directory as a potential entropy source/store. C\u003csession-token\u003e will always fail noisily if it can't read from C\u003c/dev/urandom\u003e.\n\nFinally, C\u003csession-token\u003e is easier to remember and type don't you think?\n\n\n=head1 SEE ALSO\n\nL\u003cApp-Session-Token github repo|https://github.com/hoytech/App-Session-Token\u003e\n\nL\u003cSession::Token\u003e\n\n=head1 AUTHOR\n\nDoug Hoyte, C\u003c\u003c \u003cdoug@hcsw.org\u003e \u003e\u003e\n\n=head1 COPYRIGHT \u0026 LICENSE\n\nCopyright 2014-2016 Doug Hoyte.\n\nThis module is licensed under the same terms as perl itself.\n\n=cut\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhoytech%2Fapp-session-token","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhoytech%2Fapp-session-token","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhoytech%2Fapp-session-token/lists"}