您的位置:首页 > 运维架构 > Linux

linux获取随机数的方法集合

2016-04-19 21:52 519 查看
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


本文出自 “崔德华运维打工从业路” 博客,请务必保留此出处http://cuidehua.blog.51cto.com/5449828/1765554
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: