Created
August 20, 2023 17:27
-
-
Save PlaceReporter99/62f168a73217ce5b2cd91dde6dcbc5ed to your computer and use it in GitHub Desktop.
A program that generates random numbers, which reseeds itself by querying the questions page on Stack Overflow, and hashing it. It might be cryptographically secure, it might not. I don't know.
This file contains hidden or 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
import functools | |
import hashlib | |
import time | |
from urllib.request import urlopen | |
def so_reseed(func): | |
@functools.wraps(func) | |
def wrapper(): | |
seed = hashlib.sha256(urlopen("https://stackoverflow.com/questions").read()).digest()[16] | |
while True: | |
i = func(seed) | |
yield next(i) | |
for _ in range(seed - 1): | |
time.sleep(0.5) | |
yield (b := next(i)) | |
seed = hashlib.sha256(urlopen("https://stackoverflow.com/questions").read()).digest()[b % 32] | |
return wrapper | |
@so_reseed | |
def rand_hex(seed): | |
while True: | |
temp = int(time.time() % (7**seed)) | |
seed = hashlib.sha256((str(temp)+str(time.time())).encode("utf-8")).digest()[temp % 32] | |
yield hashlib.sha256((str(seed)+str(time.time())).encode("utf-8")).digest()[temp % 32] | |
for x in rand_hex(): | |
print(x) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment