Linux生成随机字符串

Posted by アライさん on 2019年11月09日

使用openssl

1
openssl rand -base64 15

使用/dev/urandom

1
< /dev/urandom tr -cd _A-Z-a-z-0-9@#^~\ | head -c ${1:-15}; echo

使用sha256sum算法处理秒数,取前15位

1
date +%s | sha256sum | base64 | head -c 15; echo

使用md5sum算法处理秒数,取前15位

1
date +%s | md5sum | base64 | head -c 15; echo