In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-14 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
This article will explain in detail the Linux system to generate random numbers, the quality of the article content is high, so Xiaobian share for everyone to make a reference, I hope you have a certain understanding of related knowledge after reading this article.
The Linux system generates random numbers by using the system environment variable [$RANDOM], such as [echo $RANDOM]. RANDOM has a limited range of random numbers, which can be solved by adding an encrypted string after the random number.
Method 1: Through the system environment variable ($RANDOM)
[root@test ~]# echo $RANDOM11595[root@test ~]# echo $RANDOM21625
RANDOM's random number range is 0~32767, so encryption is not very good. It can be solved by adding an encrypted string (that is, a string related to password generation) after the random number, and finally performing the md5sum operation together and intercepting the last n bits of the result, so that it is impossible to guess the specific result according to the random range 0~32767.
Examples:
[root@test ~]# echo "$RANDOM"|md5sum|cut -c 5-154eaf70019cc
Method 2: Generate random numbers through openssl
Examples:
[root@test ~]# openssl rand -base64 8yB0maNWRoQw=
Random numbers are safe by combining numbers with upper and lower case characters and special characters, which can reach very long digits.
Method 3: Obtain random number by date
Examples:
[root@test ~]# date +%s%N1523402619479946400[root@test ~]# date +%s%N1523402622015235600
Method 4: Generate random numbers by combining/dev/urrandom with chksum
[root@test ~]# head /dev/urandom|cksum2866845253 2890[root@test ~]# head /dev/urandom|cksum2131526544 2440
The/dev/random device stores real-time data about the current operating environment of the system.
It can be seen as the unique value of the system at a certain time and therefore can be used as random metadata. We can read the data inside by reading the file./ dev/urrandom This device has the same data as random. Only, it's a non-blocking random number generator, and reads don't block.
About the Linux system to generate random number method to share here, I hope the above content can be of some help to everyone, you can learn more knowledge. If you think the article is good, you can share it so that more people can see it.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.