|
Forum Index : Microcontroller and PC projects : ' Hardware ' random number generators
| Author | Message | ||||
| hitsware2 Guru Joined: 03/08/2019 Location: United StatesPosts: 734 |
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: AustraliaPosts: 175 |
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: FrancePosts: 435 |
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 StatesPosts: 734 |
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: SwedenPosts: 82 |
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 KingdomPosts: 2171 |
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 StatesPosts: 734 |
Good one ! Hadn't heard of that approach . my site |
||||
| BrianP Senior Member Joined: 30/03/2017 Location: AustraliaPosts: 292 |
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 |
||||
| The Back Shed's forum code is written, and hosted, in Australia. | © JAQ Software 2025 |