Mercurial > public > purple
changeset 22:9c90ca37c023
No need to create a new set to handle a garble on encrypt.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Sun, 16 Feb 2014 14:31:24 -0600 |
parents | 6408a3f67d25 |
children | 196c3c4a15aa |
files | purple/machine.py |
diffstat | 1 files changed, 4 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/purple/machine.py Sun Feb 16 14:30:57 2014 -0600 +++ b/purple/machine.py Sun Feb 16 14:31:24 2014 -0600 @@ -1,4 +1,4 @@ -# Copyright (C) 2013 by Brian Neal. +# Copyright (C) 2013 - 2014 by Brian Neal. # This file is part of purple, the PURPLE (Cipher Machine 97) simulation. # purple is released under the MIT License (see LICENSE.txt). @@ -30,7 +30,6 @@ """ VALID_KEYS = set(string.ascii_uppercase) - VALID_DECRYPT_KEYS = set(string.ascii_uppercase + '-') STRAIGHT_PLUGBOARD = 'AEIOUYBCDFGHJKLMNPQRSTVWXZ' def __init__(self, switches_pos=None, fast_switch=1, middle_switch=2, @@ -186,8 +185,6 @@ """ plaintext = [] for i, c in enumerate(ciphertext): - if c not in self.VALID_DECRYPT_KEYS: - raise Purple97Error("invalid input '{}' to decrypt".format(c)) # Process a garble: if c == '-': @@ -195,6 +192,9 @@ self.step() continue + if c not in self.VALID_KEYS: + raise Purple97Error("invalid input '{}' to decrypt".format(c)) + n = self.plugboard[c] if n < 6: