import binascii import sys import crypto FIXED_FILE = "no-such-file" FIXED_PASS = "swordfish" FIXED_NACL = binascii.unhexlify (b"00112233445566778899aabbccddeeff") def noise (*a, **b): print (file=sys.stderr, *a, **b) def create_objects (n): """ Repeatedly apply the .next () method of the Encrypt handle for profiling. """ enc = crypto.Encrypt (1, 1, password=FIXED_PASS, nacl=FIXED_NACL) for i in range (n): _ = enc.next (FIXED_FILE) noise ("accumulated %d ivs" % len (enc.get_used_ivs ())) noise ("") noise ("** to terminate **") _ = sys.stdin.read () # halt here so we get a chance to inspec /proc/$$/status return 0 def main (argv): if len (argv) != 2: noise ("number of iterations required!") return 42 n = argv [1] n = int (n) return create_objects (n) if __name__ == "__main__": sys.exit (main (sys.argv))