-
-
Save nyimbi/513b28981b88bead55a7ed1d3d636c96 to your computer and use it in GitHub Desktop.
ANU Quantum Random Numbers API examples
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python3 | |
# Australian National University Quantum Random Numbers Generator API running on AWS | |
import json | |
import requests | |
QRN_URL = "https://api.quantumnumbers.anu.edu.au/" | |
QRN_KEY = "txxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx7" # replace with your secret API-KEY | |
DTYPE = "uint8" # uint8, uint16, hex8, hex16 | |
LENGTH = 10 # between 1--1024 | |
BLOCKSIZE = 1 # between 1--10. Only needed for hex8 and hex16 | |
params = {"length": LENGTH, "type": DTYPE, "size": BLOCKSIZE} | |
headers = {"x-api-key": QRN_KEY} | |
response = requests.get(QRN_URL, headers=headers, params=params) | |
if response.status_code == 200: | |
js = response.json() | |
if js["success"] == True: | |
print(js["data"]) | |
else: | |
print(js["message"]) | |
else: | |
print(f"Got an unexpected status-code: {response.status_code}") | |
print(response.text) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
QRN_URL=https://api.quantumnumbers.anu.edu.au/ | |
QRN_KEY=txxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx7 # replace with your secret API-KEY | |
curl -H x-api-key:${QRN_KEY} ${QRN_URL}?type=hex16\&length=10\&size=10 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment