Hacker News new | ask | show | jobs
by srollyson 4663 days ago
Can never turn down an opportunity for a one-liner.

  $ perl -E 'open(my $fh, "<", "/usr/share/dict/words"); my @words = map {chomp; $_} <$fh>; close $fh; say join " ", map {$words[int rand @words]} 1..4'
  menu chemists administrative seeps
Might have to run it a couple of times before you get something that you can memorize.
3 comments

You shouldn't use a non-cryptographically secure random number generator (perl's rand) in the context of password generation. It's too risky.
Ew.

    shuf -n 4 /usr/share/dict/words | tr -dc 'A-Za-z0-9'
You can use a dictionary of the most common 10000 words, you'd still have loads of entropy.