Linux下产生随机密码的7种方法

1

[root@test-6 ~]# date +%s | sha256sum | base64 | head -c 32 ; echo

M2U0YTllN2I1NzZjNTNjZDZhYzM5NzIz

2

[root@test-6 ~]# < /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c${1:-32};echo;

1jmWHhn9XwSOwv-1h_8DGjXFrX4lVAHf

3

[root@test-6 ~]# openssl rand -base64 32

wKKf6smfsrREu8L5FVKf9Y0o8VYwjRW3lphCrZa9kWg=

4

[root@test-6 ~]# tr -cd ‘[:alnum:]‘ < /dev/urandom | fold -w30 | head -n1

EWdZYJzdb4SIPBm6Z9iHQjfmUk

5

[root@test-6 ~]# < /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c6

或 echo `tr -dc _A-Z-a-z-0-9

Et3B46

6

[root@test-6 ~]# dd if=/dev/urandom bs=1 count=32 2>/dev/null | base64 -w 0 | rev | cut -b 2- | rev

bp/0g8JscWWHO0Nl5oFqOmXp/0RypvD27ukIMyohkR0

7

[root@test-6 ~]# date | md5sum

0bc2d0c2954a1f9d475f8714e5263cee

参考:http://blog.csdn.net/open_data/article/details/42521253