linux获取随机数的方法集合

linux产生随机的方法

取8位数字的方法

[root@master scripts]# echo $RANDOM
12465
[root@master scripts]# echo $((RANDOM+10000000))
10023190
[root@master scripts]# echo $RANDOM | md5sum | cut -c 1-8
ae74cedb
[root@master scripts]# uuidgen| md5sum | cut -c 1-8                  
fdfca8ec
[root@master scripts]# mkpasswd -l 8
6zhFj7T>
[root@master scripts]# echo `date +%s` | md5sum | cut -c 1-8
f6d58a59

更随机的方法

[root@master scripts]# echo "`date +%s`$RANDOM" | md5sum | cut -c 1-8
0daddd89
[root@master scripts]# openssl rand -base64 4
jW/xRw==
[root@master scripts]# head /dev/urandom | cksum 
1181625912 2520
[root@master scripts]# cat /proc/sys/kernel/random/uuid   == uuidgen
dfdec661-b0b7-48d3-b0db-73d1d7d09e06


你可能感兴趣的:(linux,随机数,获取)