matilde matilde on hover

Lavarand.py

[Python]

Lava Lamps can be used as a source of randomness, which can be used to establish a random number generator.
I used my Lava Lamp to generate 6 random numbers and then I used them to play SuperEnalotto (and I lost).

The script captures video from a webcam and generates random numbers using image hashes. At specific time intervals it hashes the current video frame using the SHA-1 cryptographic hash function which means it converts the frame's pixel data into a byte array. The byte array is then passed to the hash function to produce a unique hexadecimal hash string.
The hash is then converted to a numerical value by interpreting the hash as a large hexadecimal integer and taking the modulo operation (% 90) to constrain the result to a range of 0 to 89. Adding 1 ensures the final number falls between 1 and 90, making it suitable for SuperEnalotto. This process combines cryptographic randomness with real-world video data, ensuring unpredictable yet reproducible lottery numbers.

random numbers generated: [27, 6, 42, 76, 23, 2]


sourcecode