Last active
March 16, 2020 17:26
-
-
Save jay-ouellette/3cabd8916831f26f8db9fd99b62b1fb2 to your computer and use it in GitHub Desktop.
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/env python3 | |
import os | |
import sys | |
# import bz2 | |
from datetime import datetime | |
# from hashlib import blake2b | |
BYTE_COUNT = 1000 | |
BASE_TIME = 60 # in seconds | |
def main(): | |
start_time = datetime.now() | |
t = str(start_time.microsecond)[-1] | |
run_time = BASE_TIME + (10 * int(t)) | |
# generate a number from 0 to 65535 (2 bytes) | |
seed = 0 | |
count = 0 | |
while True: | |
if count == 10000: | |
now = datetime.now() | |
if (now - start_time).seconds > run_time: | |
break | |
count = 0 | |
count += 1 | |
seed = (seed + 1) % 65535 | |
a = (seed & (0xFF << 8)) >> 8 # first byte | |
m = seed & 0xFF # second byte | |
# generate bytes | |
results = bytes([a]) | |
for i in range(BYTE_COUNT - 1): | |
p = results[i] | |
results += bytes([m]) | |
m = ((p + 2) * (m + 2)) % 255 | |
# h = blake2b(digest_size=1) | |
# h.update(bytes([m])) | |
# m = int.from_bytes(h.digest(), 'big') | |
# b2 = bz2.BZ2Compressor() | |
# b2.compress(results) | |
# results = b2.flush() | |
with os.fdopen(sys.stdout.fileno(), 'wb') as f: | |
f.write(results) | |
if __name__ == "__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment