def random_stream_handler(outfile=None, size=None): bsize = 2**16 outfd = (sys.stdout.buffer if hasattr(sys.stdout, 'buffer') else sys.stdout) if not outfile else open(outfile, 'wb') if not size: while True: # write endlessly outfd.write(nacl.crypto_stream(bsize)) i = 0 size = long(size) while i <= size: if i + bsize <= size: outfd.write(nacl.crypto_stream(bsize)) i += bsize else: outfd.write(nacl.crypto_stream(size - i)) break
def random_stream_handler(outfile = None, size = None): # generates a stream of 'size' or if 'size' unspecified then # infinite random bytes into outfile or stdout if outfile is # unspecified. bsize = 2**16 outfd = sys.stdout if not outfile else open(outfile, 'w') if not size: while True: # infinite write outfd.write(nacl.crypto_stream(bsize)) i = 0 while i <= size: if i+bsize <= size: outfd.write(nacl.crypto_stream(bsize)) i+=bsize else: outfd.write(nacl.crypto_stream(size - i)) break
def test_crypto_stream(self): pysodium.crypto_stream(8) pysodium.crypto_stream(16) pysodium.crypto_stream(32)
def test_crypto_stream(self): pysodium.crypto_stream(8) pysodium.crypto_stream(16) pysodium.crypto_stream(32)