Last active
February 28, 2021 10:03
-
-
Save knwng/b71b532c95fd7c6eeb632f2860935e3d to your computer and use it in GitHub Desktop.
命令行下创建随机密码
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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