Sponsored Content
Full Discussion: Random number generation
Top Forums Programming Random number generation Post 98952 by cbkihong on Monday 13th of February 2006 09:07:35 AM
Old 02-13-2006
Would you please explain what do you mean by unsatisfactory? I suppose most applications generate random numbers with these functions for cross-platform compatibility as they are standard.

In the rand() manpage, somewhere in the bottom, there is a note that discusses how to use that properly. Did you use it like that?

http://linux.com.hk/penguin/man/3/ra...on=3&name=rand

On some systems there are other means for random number generation. For instance, on Linux PCs the /dev/hwrandom represents a hardware random number generator . But this is only present if this support is compiled and available in the kernel. You may also try /dev/random and /dev/urandom.

http://linux.com.hk:80/penguin/man/4/random.html

Code:
cbkihong:~# cat /dev/random | hexdump 
0000000 1169 ce30 3785 5b36 7afe 84ff e6f6 e637
0000010 ea63 90b5 1f59 bf52 4296 b4c1 c129 5416
0000020 2940 608e 5fed e724 fd0e 4f92 3d75 4de5
0000030 1c6f 4d22 80bf fedf a208 ff41 5163 c146
0000040 838e 9ab2 fa6d 5b51 0715 ea56 d630 99dd
0000050 6b70 2ff3 11f6 feb6 3e17 b241 e5b9 dafb
0000060 e2fd 78cd c1d2 ed64 970c e5f4 fcf1 0fad
0000070 55c0 b395 629d a43d abc1 5b1d ad28 515f
0000080 72d0 8d68 bd22 5d19 171e 4f6b d28a 9bf2
0000090 f7a0 016a 8ba9 be22 8473 34ee 3f67 3c7c
00000a0 a5ce a23c 3b36 2463 cc94 99b2 fc91 0991

Here is to show you the output looks random.
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

SQL Loader Auto Number Generation

Hi all, I have a doubt in SQL Loader. We have SEQUENCE function in SQL Loader or can create Sequence in Oracle database for generating a number sequence for a column while loading data using SQL Loader into table or multiple tables. My requirment is this. For the first run in SQL... (2 Replies)
Discussion started by: vinoth_kumar
2 Replies

2. UNIX for Dummies Questions & Answers

Random number generation in ksh

I need to generate a random number in ksh everytime I run the script ,the range should be from 100 to 24800,I could use $RANDOM but I seem to have no control over the range of numbers ,could you please suggest some way I could implement this .Thanks. Mervin (2 Replies)
Discussion started by: mervin2006
2 Replies

3. Shell Programming and Scripting

Sequence number generation on a key column

Hi Folks, Can you help me with this issue: I have to generate the numbers say from 1001 for each record in a file based on a key field, the catch is the generated number should be unique based on key column. (EMP_NUMBER) Example: Input File: EMP_NUMBER EMP_NAME 8908 ... (6 Replies)
Discussion started by: sbasetty
6 Replies

4. Shell Programming and Scripting

Regarding Random Number Genration

HI please help me in solving this issue. I have a shell script which consists of ten statemnts ( i mean 10 executable statments)...........and if i run that script the 10 statmenst will execute continously ............ But now my probelm is i have to write another script --> to... (0 Replies)
Discussion started by: lalitka
0 Replies

5. Shell Programming and Scripting

Random NUmbers Generation with out repetation

Hi I have the below code MAXCOUNT=10 count=1 echo echo "$MAXCOUNT random numbers:" echo "-----------------" while # Generate 10 ($MAXCOUNT) random integers. do number=$ + 1 ] "echo $number" let "count += 1" # Increment count. done But aftre executing this ... (8 Replies)
Discussion started by: lalitka
8 Replies

6. Shell Programming and Scripting

random number generation in ksh

i tried to use $random function in unix i simply typed print $random at shell and it returnted no value is there any function in korn shell that i can use to generate random number help is appreciated (2 Replies)
Discussion started by: er_zeeshan05
2 Replies

7. Programming

Random number is not reused

I need to generate and reuse a 5 digit random number every time my program is executed. But the following generates random numbers every time the function is called. #include <stdio.h> #include <stdlib.h> #include <sys/types.h> #include <sys/stat.h> #include <string.h> #include <time.h> ... (12 Replies)
Discussion started by: limmer
12 Replies

8. Shell Programming and Scripting

Random word generation with AWK

Hi - I have a word GTTCAGAGTTCTACAGTCCGACGAT I need to extract all the possible "chunks" of 7 or above letter "words" from this. SO, my out put should be GTTCAGA TTCAGAG TCAGAGT CAGAGTTCT TCCGACGAT CAGTCCGACG etc. How can I do that with awk or any other language? I have no... (2 Replies)
Discussion started by: polsum
2 Replies

9. Programming

random number

How can I choose randomly the row numbers of my file in awk? (4 Replies)
Discussion started by: Homa
4 Replies

10. AIX

Random password generation

Hello, I have created a script to generate a random password on Linux/Solaris, but I simply cannot use it on my AIX VMs since Bash isn't installed on them. I need a password that is randomly created with the following... (12 Replies)
Discussion started by: gfroute
12 Replies
RANDOM(4)						   BSD Kernel Interfaces Manual 						 RANDOM(4)

NAME
random , urandom -- random data source devices. SYNOPSIS
pseudo-device random DESCRIPTION
The random device produces uniformly distributed random byte values of potentially high quality. To obtain random bytes, open /dev/random for reading and read from it. To add entropy to the random generation system, open /dev/random for writing and write data that you believe to be somehow random. /dev/urandom is a compatibility nod to Linux. On Linux, /dev/urandom will produce lower quality output if the entropy pool drains, while /dev/random will prefer to block and wait for additional entropy to be collected. With Yarrow, this choice and distinction is not necessary, and the two devices behave identically. You may use either. OPERATION
The random device implements the Yarrow pseudo random number generator algorithm and maintains its entropy pool. Addditional entropy is fed to the generator regularly by the SecurityServer daemon from random jitter measurements of the kernel. SecurityServer is also responsible for periodically saving some entropy to disk and reloading it during startup to provide entropy in early system operation. You may feed additional entropy to the generator by writing it to the random device, though this is not required in a normal operating envi- ronment. LIMITATIONS AND WARNINGS
Yarrow is a fairly resilient algorithm, and is believed to be resistant to non-root. The quality of its output is however dependent on regu- lar addition of appropriate entropy. If the SecurityServer system daemon fails for any reason, output quality will suffer over time without any explicit indication from the random device itself. Paranoid programmers can counter-act this risk somewhat by collecting entropy of their choice (e.g. from keystroke or mouse timings) and seeding it into random directly before obtaining important random numbers. FILES
/dev/random /dev/urandom HISTORY
A random device appeared in Linux operating system. Darwin September 6, 2001 Darwin
All times are GMT -4. The time now is 06:24 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy