diff --git a/Caesar Cipher.py b/Caesar Cipher.py deleted file mode 100644 index b1342dc5e..000000000 --- a/Caesar Cipher.py +++ /dev/null @@ -1,38 +0,0 @@ -# The Caesar Cipher Algorithm - -message = input("Enter message: ") -key = int(input("Key [1-26]: ")) -mode = input("Encrypt or Decrypt [e/d]: ") - -if mode.lower().startswith('e'): - mode = "encrypt" -elif mode.lower().startswith('d'): - mode = "decrypt" - -LETTERS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" - -translated = "" - -message = message.upper() - -for symbol in message: - if symbol in LETTERS: - num = LETTERS.find(symbol) - if mode == "encrypt": - num = num + key - elif mode == "decrypt": - num = num - key - - if num >= len(LETTERS): - num = num - len(LETTERS) - elif num < 0: - num = num + len(LETTERS) - - translated = translated + LETTERS[num] - else: - translated = translated + symbol - -if mode == "encrypt": - print("Encryption:", translated) -elif mode == "decrypt": - print("Decryption:", translated) diff --git a/ciphers/Caesar Cipher.py b/ciphers/Caesar Cipher.py new file mode 100644 index 000000000..1689529b7 --- /dev/null +++ b/ciphers/Caesar Cipher.py @@ -0,0 +1,43 @@ +# The Caesar Cipher Algorithm + +def main(): + message = input("Enter message: ") + key = int(input("Key [1-26]: ")) + mode = input("Encrypt or Decrypt [e/d]: ") + + if mode.lower().startswith('e'): + mode = "encrypt" + elif mode.lower().startswith('d'): + mode = "decrypt" + + LETTERS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + + translated = "" + + message = message.upper() + + for symbol in message: + if symbol in LETTERS: + num = LETTERS.find(symbol) + if mode == "encrypt": + num = num + key + elif mode == "decrypt": + num = num - key + + if num >= len(LETTERS): + num = num - len(LETTERS) + elif num < 0: + num = num + len(LETTERS) + + translated = translated + LETTERS[num] + else: + translated = translated + symbol + + if mode == "encrypt": + print("Encryption:", translated) + elif mode == "decrypt": + print("Decryption:", translated) + + +if __name__ == '__main__': + main() diff --git a/Simple Substitution Cipher.py b/ciphers/Simple Substitution Cipher.py similarity index 100% rename from Simple Substitution Cipher.py rename to ciphers/Simple Substitution Cipher.py diff --git a/Transposition Cipher.py b/ciphers/Transposition Cipher.py similarity index 100% rename from Transposition Cipher.py rename to ciphers/Transposition Cipher.py diff --git a/binary_seach.py b/searches/binary_search.py similarity index 100% rename from binary_seach.py rename to searches/binary_search.py diff --git a/linear_search.py b/searches/linear_search.py similarity index 100% rename from linear_search.py rename to searches/linear_search.py diff --git a/bubble_sort.py b/sorts/bubble_sort.py similarity index 100% rename from bubble_sort.py rename to sorts/bubble_sort.py diff --git a/insertion_sort.py b/sorts/insertion_sort.py similarity index 100% rename from insertion_sort.py rename to sorts/insertion_sort.py diff --git a/merge_sort.py b/sorts/merge_sort.py similarity index 100% rename from merge_sort.py rename to sorts/merge_sort.py diff --git a/quick_sort.py b/sorts/quick_sort.py similarity index 100% rename from quick_sort.py rename to sorts/quick_sort.py diff --git a/selection_sort.py b/sorts/selection_sort.py similarity index 100% rename from selection_sort.py rename to sorts/selection_sort.py