r/programminghorror • • Oct 26 '26 • Popcorn 1 Bravo 1

c Using garbage values to generate pseudorandom numbers

Post image

Thing I came up with instead of paying attention to class today.

I tested it on this computer (windows 11 if it matters), and the first time it's ran, an actual "pseudorandom" number is returned and the following calls return 1.0 always.

2.9k Upvotes

152 comments sorted by

View all comments

Show parent comment

14

u/Top-Opportunity-5418 Oct 26 '26

Can someone explain

56

u/headedbranch225 Oct 27 '26

Recently emudhra had their private keys leaked (well cracked) and one of them was 4

https://scotthelme.co.uk/eight-bits-of-trust-emudhras-ca-keys-cracked-in-milliseconds/

A good writeup that I saw, it explains it quite well if you want to learn more

It happened the same day as the PHP vuln, I have no doubt if the PHP vulnerabilities hadn't happened at the same time it would be so much more widely covered, but if you see a much higher than usual number of references to 4 that is why

1

u/cheesengrits69 Oct 29 '26

The ol' "It's so dumb nobody would ever guess it" method

54

u/iiznobozzy Oct 26 '26

2

u/Glum-Objective3328 Oct 27 '26

Maybe a peak for relevant xkcds

1

u/Alfika07 Oct 27 '26

This panel came out in 2007. How did Randall Munroe predict the eMudhra leak?

3

u/Adventurous_Mail6397 Oct 27 '26

A Certificate Authority accidentally placed their test Private Keys into a key pool. One of the private keys was just 4.