How does a computer generate a random #?

zsouthboy

Platinum Member
Aug 14, 2001
2,264
0
0
I've always wondered that..... as computers are designed to STRICTLY follow the instructions that are given to it, how do you make a computer generate a COMPLETELY random number? I know a few programs that are psuedo-random.... but.....


??

zs
 

Elledan

Banned
Jul 24, 2000
8,880
0
0
Well, we aren't even 100% certain that anything can be truly random.

But there are some (PCI-)cards which can be used to generate a random number, by taking some electrical noise or something similar as the 'seed'.
 

thaneboy

Member
Oct 29, 1999
158
0
0
The computer or the programmer can make random no by using date and time which are always varying constantly
 

CTho9305

Elite Member
Jul 26, 2000
9,214
1
81
excluding what elledan said, you can't. it can make really really good pseudo-random numbers, but thats it. for randomness, you need to start measuring thermal/electrical variations.

what thaneboy said isn't really correct... you use the date as a seed to create the pseudorandom numbers.

but anyway, since I have no knowledge of quantum mechanics, i'll argue that "god does not play dice with the universe"
 

RolyL

Senior member
Jul 14, 2001
258
0
0
how do you make a computer generate a COMPLETELY random number?

One can't readily at the moment. As already mentioned, the clock and noise can be used, but the resulting numbers are still the output of a traceable process and so aren't really 'random' (although seemingly perfectably acceptably distributed). In the past, tables of 'random numbers' were used.

As certain quantum effects appear random, I suppose something monitoring these could be used for an improvement. Dunno whether anyone has done this yet.
 

woolmilk

Member
Dec 9, 2001
120
0
0

Another approach to get some randomness is the measurement of mousemovements or other random user interaction.
Date&Time are bad for encryption if the attacker can guess the moment of encryption. He can limit the number of possible
passwords to a few millions.


 

blahblah99

Platinum Member
Oct 10, 2000
2,689
0
0
There's no such thing as a true random number generator when it comes to computers, but the closest is those rng they use in casino machines. But there are some ways to achieve some randomness like others have said... one way is to get a high gain antenna and feed the voltage recieved through a data acquistion device, and use that result to seed the rand() function. Atomic decay is another form of randomness....

Interestingly, you can also use some linear algebra to get a pseudo-random generator.
 

m0ti

Senior member
Jul 6, 2001
975
0
0
If you want to get a good look check out the source code for the Random object in Java.


Basically, as far as I can remember, it gets an initial seed as a parameter (often, this seed is passed as the current time). Whenever a random number is requested it generates it updates the seed to a new one by multiplying it a bit masking, as well as doing arithmetic could be logical, makes no real big diff) shifts), and uses that seed to generate the approrpiate number, again via a similar process of multiplyinh masking dividing, etc. The code is really tight and simple.
 

Carceri

Member
Aug 7, 2001
119
0
0
As many people have said computers can't generate a truely random number on their own. Normally you use pseudo random number generators which can be thought of as a big cycle of numbers (or a function that you can use to always get the next number in the cycle). Then you get some truely random numbers (as good as you can) by measuring radiation, heat, user typing on the keyboard, etc. and that number you get desides where you enter the cycle. From that point on if you follow the cycle, it should not be possible to distinguish the numbers you get from truely random numbers. Of cause since the cycle has limited length (although VERY large - sometimes in the order of 2^500 or larger) the change that you get the same sequence of random numbers is negligible. Still the numbers you get are not truely random.

You can use a quantum computer to generate random numbers. Prepare a qbit in an equal superposition of 1 and 0 and measure it. You'll get 1 with probability ½ and 0 with probability ½.
 

Locutus4657

Senior member
Oct 9, 2001
209
0
0
In most programs the "random" number isn't really random, but very deterministic. The reason it's determainistic is because it's based on an equation, which means if you know the equation you can start predicting the number. As a matter of fact C's rand() function will continue to produce the same "random" numbers unless you change the seed.
 

zsouthboy

Platinum Member
Aug 14, 2001
2,264
0
0
Yeah.... but once we get quantum computers.... they can break encryption VERY fast..... so we'll have to figure something else out....

zs
 

Elledan

Banned
Jul 24, 2000
8,880
0
0


<< Yeah.... but once we get quantum computers.... they can break encryption VERY fast..... so we'll have to figure something else out....

zs
>>

Two words: Quantum Encryption.

It'll make it impossible to read encrypted data unless you've got a couple of million years to spare while waiting for the one lucky arrangement of the data.
 

Carceri

Member
Aug 7, 2001
119
0
0
I will not go into discussing quantum computing and quantum encryption in detail since I have done that a few times before on this board. I will just point out that it's a common misunderstanding that quamtum computers can be used to break all encryption. Let's look at what they can actually do:

"Unconditionally secure" systems (such as the one time pad): Well, these have already been proven to be unbreakable in theory and that can't be changed by a quantum computer. In fact we can use quantum cryptography to generate a stream of bits known only to the sender and the receiver and then use these bits as the key to the one time pad. That will provide unconditional security (even if you have unlimited resources you can't break it) if done right. The BB84 QKD protocol describes how to do this.

Public key systems: Most of these are based on variations of the hidden subgroup problem which can be solved exponentionally faster with a quantum computer so most of these will fail (that includes RSA and DH). However, since a quantum computer can't solve NP complete problems efficiently, public key systems based on NP complete problems (there are a few, although not well known ones) will remain secure (unless there are other flaws in the algorithm of cause)

Symmetric ciphers: Can be attacked using quantum search which gives a quadratic speedup, That is a 128 bit key will be equivalent to a 64 bit key on a conventional computer. Since today most new algorithms use 256 bit keys, these will still remain computationally secure against a quantum computer.
 

StandardCell

Senior member
Sep 2, 2001
312
0
0
Just to add my two cents to the discussion, a computer uses a pseudo random pattern generator called an Autonomous Linear Feedback Shift Register (or ALFSR for short) in software. What the ALFSR is is a series of 2-input XOR gates with flops between stages, in a pattern thus:

XOR-flop-XOR-flop-XOR-flop---(output back to one input of every XOR)

This structure represents a binary polynomial P(x)=aNx^N+aN-1 x^N-1+...+a1 x + 1, where the an's represent either a 1 or zero (either an XOR or a bypass) and N is the polynomial length. Assuming we've preloaded with a binary seed somewhere within the sequence, on a clock to the flops information will propage through and then the last bit back to all the flops. The net result is that you have what appears to be randomly distributed binary numbers off the flop outputs. This will cycle numbers up to a maximum of (2^N)-1 combinations. Zero is not allowed to be used as a random seed since it will always give zero output.

The polynomial selection is a science in and of itself, the goal of which is to have a full representation of all of the polynomial output. For example, P(x)=X^3+X+1 is unique and will produce a random combination of 3 bit numbers from 001 to 111, but in a pseudo-random order. There are larger order polynomials that are documented but I don't have that handy. Some polynomials are not full sequence and will not give all (2^N)-1 possible combinations.

This type of random number generation is useful in test pattern generation for digital chips. They use this polynomial and an inverse function called a compactor, and they drive random data through the chip as it's clocked. An expected pattern is known to be at the output of the test compactor that is compared to check if the digital chip has connectivity problems known as stuck-at faults typical of the manufacturing process. The ALFSR can either generate external patterns that are applied to the chip, or be embedded into the chip for BIST (built-in self test). Of course, there are unlimited software applications of random numbers but I'll leave that to the more software-oriented folks to discuss.

As for the random seed itself (i.e. the starting point of the ALFSR), I'm not aware of any processor instruction like rand() but conceivably it could be a number of things, from the system clock date/time to an antenna measuring random noise, provided that it's not zero. Also, if you know which pattern you want to start from in a test situation you can just choose that. But people already covered that in this thread.
 

MikeMAN

Senior member
Oct 26, 1999
743
6
81
i was wondering, in a program like VB or C++ I heard something about them using Augmented Matricies....but maybe that was only VB..because of the object-oriented nature..

i was wondering myself

any info is appreciated..

mike
 

Moohooya

Senior member
Oct 10, 1999
677
0
0
Generating a random seed as said above, may be impossable. However, generating a good enough seed is easy. Take any combination of the following.

Current time.
CPU MM timer
Time since last reboot.
Mouse position.
Time since last key press.
Last key pressed.
CPU temperature.
Amount of free system memory.
Current CPU usage.
and I'm sure you can add more.

There are many decent algorithms for decent random number generation assuming you have a seed. (See Knuth) From the above you can take the least significant changing bits to ensure you don't get useless constant or repetative, or predictable values. While this will not make a great randon number generator as the mouse may not move before the next value, the CPU will stay about the same temp and so on, from one day to the next the seeds should be fairly unique.

There are also some great hashing algorithums. Take all your seed values, and generate a hash of them. If one bit changes, you'll end up with a very different seed. This should help if you feel that your seed values while always different may be similar.
 

Danzilla

Platinum Member
Dec 30, 2000
2,747
0
76
I remeber when I was first starting to program. I was using a IBM PC-Jr in junior high. I wrote a simple program to display circles of ramdom size, color, and position. Much to my surprise, the same exact graphics appeared again and again and etc., every time the program ran. So much for the 'random' number generator. I don't think there was even an option to change the seed value, but that was a long time ago.

D.
 

DuffMan

Junior Member
Jan 25, 2002
8
0
0


<< i was wondering, in a program like VB or C++ I heard something about them using Augmented Matricies....but maybe that was only VB..because of the object-oriented nature..

i was wondering myself

any info is appreciated..

mike
>>



VB is object-based, not object-oriented. Theres a difference
C++ is object-oriented and it can do anything vb can do as far as the final product is concerned.
 

Locutus4657

Senior member
Oct 9, 2001
209
0
0
Any turing complete language can do anything VB can do in the final product... Object-Oriented and Object-Based are just different ways too code. For instance C can do anything C++ can do, as a matter of fact C++ classes are pretty much a cleaner version of C structures.



<<

<< i was wondering, in a program like VB or C++ I heard something about them using Augmented Matricies....but maybe that was only VB..because of the object-oriented nature..

i was wondering myself

any info is appreciated..

mike
>>



VB is object-based, not object-oriented. Theres a difference
C++ is object-oriented and it can do anything vb can do as far as the final product is concerned.
>>

 

RaynorWolfcastle

Diamond Member
Feb 8, 2001
8,968
16
81
Wasn't Intel going to put in true random number generators in the coppermine pIII's? I vaguely recall reading something to that effect, it was during the time the serial # identification debate was raging. It was supposed to generate random numbers based on "sub-atomic buzz" which I imagine is layman's terms for some quantum mechanic effect. I guess they scrapped that idea since I have not heard of it since.

CTho9305, check out the sig, you'll get a kick out of it

-Ice
 

Carceri

Member
Aug 7, 2001
119
0
0
Intel have implemented a RNG in some of their chipsets and CPUs. They can be used in combination with other methods to generate better seeds. They have absolutely nothing to do with quantum mechanics.
 

Peter

Elite Member
Oct 15, 1999
9,640
1
0
No, that's in Intel's Firmware Hub device. See Linux sources on how to use it. (You'll find the device only in systems
with Intel 8xx chipsets, and even there you might find someone else's FWH used.)

regards, Peter
 

nortexoid

Diamond Member
May 1, 2000
4,096
0
0
throw yourself on the number pad...it should generate a string of random numbers when it breaks your fall...

likewise, let a monkey type on the numberpad...assuming u aren't one yourself.

hi, my name is random.

if u change the 'd' to an 's', it spells another word.

hi.
 
sale-70-410-exam    | Exam-200-125-pdf    | we-sale-70-410-exam    | hot-sale-70-410-exam    | Latest-exam-700-603-Dumps    | Dumps-98-363-exams-date    | Certs-200-125-date    | Dumps-300-075-exams-date    | hot-sale-book-C8010-726-book    | Hot-Sale-200-310-Exam    | Exam-Description-200-310-dumps?    | hot-sale-book-200-125-book    | Latest-Updated-300-209-Exam    | Dumps-210-260-exams-date    | Download-200-125-Exam-PDF    | Exam-Description-300-101-dumps    | Certs-300-101-date    | Hot-Sale-300-075-Exam    | Latest-exam-200-125-Dumps    | Exam-Description-200-125-dumps    | Latest-Updated-300-075-Exam    | hot-sale-book-210-260-book    | Dumps-200-901-exams-date    | Certs-200-901-date    | Latest-exam-1Z0-062-Dumps    | Hot-Sale-1Z0-062-Exam    | Certs-CSSLP-date    | 100%-Pass-70-383-Exams    | Latest-JN0-360-real-exam-questions    | 100%-Pass-4A0-100-Real-Exam-Questions    | Dumps-300-135-exams-date    | Passed-200-105-Tech-Exams    | Latest-Updated-200-310-Exam    | Download-300-070-Exam-PDF    | Hot-Sale-JN0-360-Exam    | 100%-Pass-JN0-360-Exams    | 100%-Pass-JN0-360-Real-Exam-Questions    | Dumps-JN0-360-exams-date    | Exam-Description-1Z0-876-dumps    | Latest-exam-1Z0-876-Dumps    | Dumps-HPE0-Y53-exams-date    | 2017-Latest-HPE0-Y53-Exam    | 100%-Pass-HPE0-Y53-Real-Exam-Questions    | Pass-4A0-100-Exam    | Latest-4A0-100-Questions    | Dumps-98-365-exams-date    | 2017-Latest-98-365-Exam    | 100%-Pass-VCS-254-Exams    | 2017-Latest-VCS-273-Exam    | Dumps-200-355-exams-date    | 2017-Latest-300-320-Exam    | Pass-300-101-Exam    | 100%-Pass-300-115-Exams    |
http://www.portvapes.co.uk/    | http://www.portvapes.co.uk/    |