Tutorials
Step-by-step guides to help you integrate TrueEntropy quantum randomness into real-world applications.
Getting Your First Quantum Random Numbers
Generate your first quantum random integers in under 2 minutes.
1. Get an API key
Sign up at trueentropy.net/register and create an API key from your dashboard.
2. Make your first request
Terminal
curl https://api.trueentropy.net/v1/integers \
-H "Authorization: Bearer te_live_YOUR_KEY" \
-G -d "count=5&min=1&max=100"
3. Check the response
{
"data": {
"values": [42, 87, 13, 65, 91],
"count": 5
},
"metadata": {
"nist_verified": true,
"powered_by": "QuBitLang"
}
}
Every value is backed by real quantum hardware - confirmed by the nist_verified: true flag.
Building a Quantum Lottery Draw
Create a provably fair lottery draw using quantum randomness with full audit trail.
lottery.py
from trueentropy import TrueEntropy
client = TrueEntropy(api_key="te_live_YOUR_KEY")
# Draw 6 unique numbers from 1-49
pool = list(range(1, 50))
result = client.shuffle(items=pool)
draw = sorted(result.shuffled[:6])
print(f"Winning numbers: {draw}")
print(f"Certificate: {result.metadata.certificate_id}")
print(f"Verify: https://trueentropy.net/verify/?id={result.metadata.certificate_id}")
The certificate URL can be published publicly so anyone can verify the draw was quantum-random.
Generating Cryptographic Keys
Use quantum entropy for cryptographic key material with maximum security.
keygen.py
from trueentropy import TrueEntropy
client = TrueEntropy(api_key="te_live_YOUR_KEY")
# Generate a 256-bit AES key
result = client.bytes(count=32, encoding="hex")
print(f"AES-256 key: {result.bytes}")
# Generate a session nonce
nonce = client.bytes(count=16, encoding="base64")
print(f"Nonce: {nonce.bytes}")
# Generate a quantum UUID for a session ID
session = client.uuid(count=1)
print(f"Session ID: {session.uuids[0]}")
Monte Carlo Simulation with Quantum Floats
Use truly random floats for Monte Carlo simulations with provably unbiased sampling.
monte_carlo.py
from trueentropy import TrueEntropy
import math
client = TrueEntropy(api_key="te_live_YOUR_KEY")
# Estimate Pi using quantum random points
n = 10000
result = client.floats(count=n * 2, precision=10)
inside = 0
for i in range(0, n * 2, 2):
x, y = result.values[i], result.values[i+1]
if x**2 + y**2 <= 1:
inside += 1
pi_estimate = 4 * inside / n
print(f"Pi ≈ {pi_estimate:.6f} (actual: {math.pi:.6f})")