Skip to content

Instantly share code, notes, and snippets.

@knwng
Last active February 28, 2021 10:03
Show Gist options
  • Save knwng/b71b532c95fd7c6eeb632f2860935e3d to your computer and use it in GitHub Desktop.
Save knwng/b71b532c95fd7c6eeb632f2860935e3d to your computer and use it in GitHub Desktop.
命令行下创建随机密码
#!/bin/sh
LENGTH=32
# use openssl
openssl rand ${LENGTH} -base64
# use gpg
gpg --gen-random --armor 1 ${LENGTH}
# get string directly from urandom
# this approach will generate password composed of only alphabet and number.
cat /dev/urandom | strings | tr -dc A-Za-z0-9 | head -c 32; echo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment