Skip to content

Instantly share code, notes, and snippets.

@rkasigi
Last active February 5, 2024 16:39
Show Gist options
  • Star 12 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save rkasigi/cf6d5fcc83f821ab2e2bd012c2a0981a to your computer and use it in GitHub Desktop.
Save rkasigi/cf6d5fcc83f821ab2e2bd012c2a0981a to your computer and use it in GitHub Desktop.
OSX Generate Random String
openssl rand -base64 6
openssl rand -hex 4
openssl rand -base64 8 | md5 | head -c8;echo
openssl rand -base64 6
ping -c 1 yahoo.com |md5 | head -c8; echo
env LC_CTYPE=C tr -dc "a-zA-Z0-9-_\$\?" < /dev/urandom | head -c 10
cat /dev/urandom | env LC_CTYPE=C tr -dc a-zA-Z0-9 | head -c 16; echo
Generate random password on Mac OS X
Feel free to put this in your ~/.profile:
random(){ cat /dev/urandom | env LC_CTYPE=C tr -dc $1 | head -c $2; echo; }
Then use it to generate passwords:
random [:alnum:] 16
Or DNA sequences:
random ACGT 256
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment