Last active
December 12, 2019 01:36
-
-
Save blackrobot/e8bda187045a6f49aee8778b8fcefc7e to your computer and use it in GitHub Desktop.
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 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")) |
This will be helpful too: https://stackoverflow.com/questions/908331/how-to-write-binary-data-to-stdout-in-python-3
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
$ python dev_pyrandom.py | head -c16