def main(): try: name = sys.argv[1] except IndexError: raise SystemExit('Enter cipher module to test.') cipher_module = import_cipher_module(name) _test(cipher_module)
def main(): args = parse_args() cipher_name = args.cipher if args.debug: logging.basicConfig(level=logging.DEBUG) hacker = import_cipher_module(cipher_name, module_name='hacker') if args.infile: hacker.hack(args.infile.read()) else: hacker.hack()
def main(): args = parse_args() if args.debug: logging.basicConfig(level=logging.DEBUG) message = args.infile.read() cipher = import_cipher_module(args.cipher) if not args.key: args.key = cipher.get_random_key(message) print('Using random key {}'.format(args.key), file=sys.stderr) start_time = time.time() if not args.decrypt: mode = 'encrypt' print(cipher.encrypt(args.key, message), file=args.outfile) else: mode = 'decrypt' print(cipher.decrypt(args.key, message), file=args.outfile) total_time = round(time.time() - start_time, 2) print('{}ion time: {} seconds'.format(mode, total_time), file=sys.stderr)