# https://stackoverflow.com/a/18266970 from Crypto.PublicKey import RSA from Crypto.Hash import HMAC from struct import pack from hashlib import sha3_512 from cryptography.hazmat.primitives.serialization import load_der_private_key from functools import cache from cache_to_disk import cache_to_disk class PRNG(object): def __init__(self, seed): self.index = 0 self.seed = sha3_512(seed).digest() self.buffer = b"" def __call__(self, n): while len(self.buffer) < n: self.buffer += sha3_512(self.seed + pack("