Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 21:08 14 Nov 2025 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : ' Hardware ' random number generators

Author Message
hitsware2

Guru

Joined: 03/08/2019
Location: United States
Posts: 734
Posted: 03:07pm 10 Sep 2020
Copy link to clipboard 
Print this post

  Quote  
For the random number seed, a spare floating analog input is handy.


spare = 23 ' any spare analog pin left floating.
setpin spare, ain
RANDOMIZE pin(spare)*1000
print rnd()

Yes !  
That explains why the same ( newer )
chips with ' hardware random number generators '
are the ones with analog inputs !
my site
 
MustardMan

Senior Member

Joined: 30/08/2019
Location: Australia
Posts: 175
Posted: 11:25pm 10 Sep 2020
Copy link to clipboard 
Print this post

Quite possibly!

There are more sophisticated ways of doing it, and depending on needs (ie: do you want a completely random sequence, or is a random seed to a PRNG enough). Doing an ADC on an input is quite slow and very suitable for the latter, but if you want lots of numbers and want them quickly, some dedicated hardware is best.

Cheers,
 
goc30

Guru

Joined: 12/04/2017
Location: France
Posts: 435
Posted: 12:59am 11 Sep 2020
Copy link to clipboard 
Print this post

when i was younger i had written a random number generation function based on an RC circuit. The principle was based on the instability of the circuit in time. With very average components, the value of time base is fixed, but it can changes between 2 values, for example if you have an RC for 50ms, this value change from 49 to 51ms (temp, hum, old components, etc..). It was then enough to count the duration of the pulse, in µsec, to have a number which varies from 1 to x, randomly.
Edited 2020-09-11 11:04 by goc30
 
hitsware2

Guru

Joined: 03/08/2019
Location: United States
Posts: 734
Posted: 02:42am 11 Sep 2020
Copy link to clipboard 
Print this post

BTW .... Original quote & code from Tassy Jim

> There are more sophisticated ways of doing it,

I cant imagine how an algorithm could be unpredictable .
Leaving only analog ( if only for the ' seed ' )
as the only means .
Though the sensing could be something besides voltage .
I . E ... solar cell or geiger counter .
my site
 
JoOngle
Regular Member

Joined: 25/07/2020
Location: Sweden
Posts: 82
Posted: 03:11am 11 Sep 2020
Copy link to clipboard 
Print this post

Or, you can use a noisy Germanium diode with some extra components, like a transistor to amplify the signal somewhere between 0-5v (with a 3.3v converter) and a schmitt trigger perhaps?

Should be quite random, as the noisy Germanium diode can generate white noise when abused properly ;)
 
CaptainBoing

Guru

Joined: 07/09/2016
Location: United Kingdom
Posts: 2171
Posted: 07:03am 11 Sep 2020
Copy link to clipboard 
Print this post

I played with this a while back. This goes into explaining how/why a TRNG seed can be quite effective as a starting place for PRNG with some very good resources cited in the article.

http://www.fruitoftheshed.com/Circuit%20Ideas.Random-Bit-Generator-for-cryptographic-strength-random-numbers.ashx

and the code for it

http://www.fruitoftheshed.com/MMBasic.True-Random-Generator-companion-code-for-circuit.ashx
 
hitsware2

Guru

Joined: 03/08/2019
Location: United States
Posts: 734
Posted: 08:49am 11 Sep 2020
Copy link to clipboard 
Print this post

  goc30 said  when i was younger i had written a random number generation function based on an RC circuit. The principle was based on the instability of the circuit in time. With very average components, the value of time base is fixed, but it can changes between 2 values, for example if you have an RC for 50ms, this value change from 49 to 51ms (temp, hum, old components, etc..). It was then enough to count the duration of the pulse, in µsec, to have a number which varies from 1 to x, randomly.

Good one !
Hadn't heard of that approach .
my site
 
BrianP
Senior Member

Joined: 30/03/2017
Location: Australia
Posts: 292
Posted: 10:39pm 11 Sep 2020
Copy link to clipboard 
Print this post

I was told that there is an entity in the US of A that uses the camera image of a wall of lava lamps for their RNG seed
Should be enough entropy?

B
 
Print this page


To reply to this topic, you need to log in.

The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025