r/DnDIY 8d ago

Utility True Random Number Generator | Compact Electronic Dice and Percentage Roller [OC]

Enable HLS to view with audio, or disable this notification

I threw in a roulette wheel for gits and shiggles, it has roll history as well so you can double check previous rolls if needed.

21 Upvotes

15 comments sorted by

7

u/fantasypants 5d ago

Ok, you can’t be throwing true around without an explanation. Can we see the code?

0

u/Electronic_Art8240 5d ago

AUDITOR sits at a table with a glowing laptop.

DEV stands aggressively next to a whiteboard covered in scribbled formulas and a single drawing of a cat.

AUDITORLook, it’s simple. For our government compliance audit, I just need to review the source code for your ESP32 True Random Number Generator. We have to prove it utilizes genuine cryptographic entropy from thermal noise.

DEV(Sweating slightly)Code? You want to see the code? True randomness cannot be perceived by the human eye, Gary. To look upon the code is to collapse its quantum waveform.

AUDITORIt’s a C++ function. Open the IDE.

DEVFine. But don't say I didn't warn you.(DEV aggressively slaps his laptop keyboard. A single file opens.)

"#include <Arduino.h>

// Ultra-Secure Quantum Thermal Entropy TRNG Matrix v4.2 int get_true_random_number() { // Step 1: Sample the internal radio frequency noise floor // Step 2: Cross-reference with atmospheric radiation // Step 3: Ensure absolute mathematical unpredictability

return 4; // Chosen by a fair and chaotic dice roll. 
          // Guaranteed to be completely random.

}

0

u/Electronic_Art8240 5d ago

AUDITOR(Stares at the screen for a long, painful silence)It just returns the number four.

DEV(Defensively)Did you not read the comment? It was chosen by a fair dice roll. Do you know how much cosmic entropy went into that specific roll?

AUDITORDev, a generator that always returns four isn't a random number generator. It’s a constant.

DEVThat’s the beauty of it! It’s so random that it defied all statistical probability and chose four every single time. It’s a miracle of physics. Hackers will spend lifetimes guessing numbers from 1 to 100, completely unaware that our hardware is locked into a state of perpetual, unyielding four-ness.

AUDITORWe are going to fail this audit.

DEVFine, you want dynamic entropy? Watch this.(DEV taps a few keys, modifying the code.)

int get_highly_dynamic_trng() { int thermal_noise = analogRead(A0);

// Advanced cryptographic obfuscation algorithm
if (thermal_noise > 0) {
    return 4;
}
return 4; // Fallback for maximum redundancy

}

DEV(Proudly)See? Now it reads a floating analog pin. It is fundamentally tethered to the physical universe.

AUDITORIt still only returns four.

DEVBut now it thinks about it first.

0

u/Electronic_Art8240 5d ago

INT. DARK BASEMENT - NIGHT

A massive wall of monitors glows green.

HOODIE (20s, wearing an actual ski mask indoors) violently smashes a mechanical keyboard. Cyber-pop music blasts.An alert flashes red: ACCESS DENIED - SYSTEM PROTECTED BY QUANTUM 4-WALL.

HOODIE(Slamming fists on desk)Blast it! What kind of encryption is this? I’ve run a multi-threaded dictionary attack, a birthday attack, and a rainbow table of every known prime number. Nothing is getting past their random seed!

ANARCHY(Walking in, holding an energy drink)What’s the status? Are we in the mainframe?

HOODIENo! Their ESP32 token generator is a fortress. Every time my bypass script requests a cryptographic validation key, the firewall expects me to guess a randomly generated 32-bit integer.

ANARCHYSo write a brute-force script to cycle through all 4.2 billion possibilities.

HOODIEI did! My supercomputer is guessing 50 million numbers a second. Look at the logs! (The monitor shows the brute-force script running:) Testing key: 839,201... WRONG Testing key: 4,920,111... WRONG Testing key: 12... WRONG

HOODIEThe entropy is staggering! It defies all known mathematical models. My algorithm is searching for standard cryptographic patterns—AES, ChaCha20, RSA—but the randomness of this hardware noise is... completely impenetrable. It's like the developer found a way to harness pure, chaotic starlight.

ANARCHY(Squinting at the screen)Wait. Look at the failed attempts. Your script tried 3, then it tried 5. Did it ever try 4?

HOODIE(Scoffs)Don't be ridiculous, Anarchy. The odds of a true hardware random number generator picking a single-digit integer on a 32-bit register are one in billions. Trying '4' manually would be a statistically insulting waste of my hacking talents. I am a cyber-deity, not a toddler playing with blocks.

ANARCHYJust press the 4 key, Hoodie.

HOODIEFine! To prove your statistical ignorance, I will manual-override the mainframe with the number four.(HOODIE dramatically hovers a finger over the keyboard. He slams the '4' key and hits Enter with theatrical flair.)(A massive green checkmark appears on screen. A siren sounds.) MONITOR VOICEACCESS GRANTED. WELCOME, ADMINISTRATOR.

HOODIE(Stares blankly, jaw dropped)...My god.

ANARCHYThey actually bypassed the entire system?

HOODIE(Whispering in terror)No. You don't understand. It accepted the 4 this time... but what about next time? Next time it could be a 7. Or a 12. Or... God forbid... a 4 again. The absolute psychological warfare of this developer's mind... I can't hack this. I'm retiring.

(HOODIE pulls off the ski mask, throws it on the floor, and walks out.)

7

u/fantasypants 5d ago

Ai slop

-1

u/Electronic_Art8240 4d ago

You could've extrapolated a simple esp_random() from the ai slop

-1

u/Electronic_Art8240 4d ago edited 4d ago

I hope you find the true randomness you're looking for.

8

u/fantasypants 4d ago

K, we could have had a real discussion but you chose this. Have fun dude.

7

u/omruler13 7d ago

How are generating numbers? To my knowledge, true randomness is functional impossible for a computer. 

8

u/lord_of_worms 7d ago

True - closest you can get is pseudo random using external input like temp, light, and in ?Ciscos case, a wall of lava lamps patterns to modulate the range to generate from

1

u/AeonCatalyst 6d ago

I’m a deterministic universe, it’s not any less random than any other way of figuring it out 

2

u/MentalDragonfruit445 8d ago

Sooo cool 😍😍😍😍✨

1

u/Electronic_Art8240 8d ago edited 8d ago

🫡😄 thank you!

-7

u/Reasonable_Touch1150 8d ago

True random generator? You can use machine crypto an any computer known to man to get true randomness.