Skip to content

Instantly share code, notes, and snippets.

@idleuncle
Last active May 6, 2019 15:06
Show Gist options
  • Save idleuncle/309aa50bd24c38404351579e846b0c83 to your computer and use it in GitHub Desktop.
Save idleuncle/309aa50bd24c38404351579e846b0c83 to your computer and use it in GitHub Desktop.
随机生成密码
openssl rand -base64 8 | cut -c 1-9
# 生成128位随机串
cat /dev/urandom | od -X -N 16 | head -n 1 | cut -d ' ' -f 2- | tr -d ' '
# 生成8字节长度随机串,27 = 9 + 16
cat /dev/urandom | od -x | head -c 27 | cut -d ' ' -f 2- | tr -d ' '
# 生成16字节长度随机串,41 = 9 + 32
cat /dev/urandom | od -x | head -c 41 | cut -d ' ' -f 2- | tr -d ' '
# 生成32字节长度随机串(最长32字节)
cat /dev/urandom | od -x | head -n 1 | cut -d ' ' -f 2- | tr -d ' '
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment