How To Generate Random Numbers In Linux? – POFTUT

How To Generate Random Numbers In Linux?

Generating random numbers can be seem odd. But it is very important for security. In security field whatever best cipher or algorithm you use if you can’t generate random numbers it is useless from point of view of security. So how can we generate random numbers in Linux environment.

Generate With urandom File

urandom is a device which resides under the /dev . We can read this  file which will output some binary values. We can use cat or similar command to print or redirect into a file.

Generate With Openssl

Second option is to use OpenSSL which is core security library for a lot of application. OpenSSL rand 256 command will generate 256 byte of random data with binary format. to generate more readable format like hex use -hex option  rand -hex 256

Generate With Python

Third option is using python random library. But this library generates random numbers rather than random data. We will use random module and random() function like below. This will generate random number between 1 and 0 .

Leave a Reply

Your email address will not be published. Required fields are marked *

Enjoy this blog? Please spread the word :)