From ee3b0f2e50b78f3a8a2ca1b4937502da68d3db35 Mon Sep 17 00:00:00 2001 From: cclauss Date: Mon, 2 Jul 2018 10:11:28 +0200 Subject: [PATCH 1/2] Properly define raw_input)( in Python 3 __raw_input()__ was removed in Python 3 in favor of __input()__. This change ensure similar functioning in both Python 2 and Python 3. --- hashes/chaos_machine.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/hashes/chaos_machine.py b/hashes/chaos_machine.py index 766dbba3c..4b30f631a 100644 --- a/hashes/chaos_machine.py +++ b/hashes/chaos_machine.py @@ -2,10 +2,9 @@ from __future__ import print_function try: - raw_input - input = raw_input -except: - pass + raw_input # Python 2 +except NameError: + input = raw_input # Python 3 # Chaos Machine (K, t, m) K = [0.33, 0.44, 0.55, 0.44, 0.33]; t = 3; m = 5 From bec160c6dc651442a37edafe85245a7856a2a142 Mon Sep 17 00:00:00 2001 From: cclauss Date: Tue, 3 Jul 2018 08:33:38 +0200 Subject: [PATCH 2/2] Use strip() to deal with leading or trailing whitespace --- hashes/chaos_machine.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/hashes/chaos_machine.py b/hashes/chaos_machine.py index 4b30f631a..f0a305bfe 100644 --- a/hashes/chaos_machine.py +++ b/hashes/chaos_machine.py @@ -2,9 +2,9 @@ from __future__ import print_function try: - raw_input # Python 2 + input = raw_input # Python 2 except NameError: - input = raw_input # Python 3 + pass # Python 3 # Chaos Machine (K, t, m) K = [0.33, 0.44, 0.55, 0.44, 0.33]; t = 3; m = 5 @@ -100,7 +100,7 @@ for chunk in message: inp = "" # Pulling Data (Output) -while inp != "e" and inp != "E": +while inp in ("e", "E"): print("%s" % format(pull(), '#04x')) print(buffer_space); print(params_space) - inp = input("(e)exit? ") + inp = input("(e)exit? ").strip()