Skip to content

Instantly share code, notes, and snippets.

@blackrobot

blackrobot/dev_pyrandom.py

Last active Dec 12, 2019
Embed
What would you like to do?
import time
import requests
MAX_UNICODE = 0x10ffff
def rand_bytes():
resp = requests.get("https://en.wikipedia.org/wiki/Special:Random")
content = resp.content
start = len(content) // 2
for x, y in zip(content[:start], content[start:]):
value = x * y * time.time()
yield chr(int(value % MAX_UNICODE))
if __name__ == "__main__":
import sys
for rand_byte in rand_bytes():
sys.stdout.buffer.write(rand_byte.encode("utf8"))
@blackrobot

This comment has been minimized.

Copy link
Owner Author

@blackrobot blackrobot commented Dec 12, 2019

$ python dev_pyrandom.py | head -c16
@blackrobot

This comment has been minimized.

Copy link
Owner Author

@blackrobot blackrobot commented Dec 12, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.