From 74275e823f51a8628d55b6f30f2e09b138820076 Mon Sep 17 00:00:00 2001 From: Josh Mudge Date: Sat, 29 Sep 2018 17:08:01 -0600 Subject: [PATCH] Fixed bug with spaces. Added README. --- Caeser-Cipher/README.md | 28 ++++++++++++++++++++++++++++ Caeser-Cipher/caeser-cipher.py | 6 +++--- 2 files changed, 31 insertions(+), 3 deletions(-) create mode 100644 Caeser-Cipher/README.md diff --git a/Caeser-Cipher/README.md b/Caeser-Cipher/README.md new file mode 100644 index 0000000..60963fa --- /dev/null +++ b/Caeser-Cipher/README.md @@ -0,0 +1,28 @@ +# Python Caeser Cipher Helper + +# What's That? + +This script gives you tools to manipulate text with the Caeser Cipher. +It'll take any input you give it, filter it and process it as you want (encrypt or decrypt) and will attempt to crack it if you don't know the shift. + +This is a fun tool, not security. The Caeser Cipher was broken in A.D. 800 (or earlier) for longer messages unless you use a one time pad and a randomly generated shift. But, it's fun to break and manipulate. + +This tool is a work in progress. + +# Requirements + + Python `=>` 3.5.2 + +# Usage + +### Encrypt + +`python3 caeser-cipher.py encrypt "secretmessage"` + +For example: `python3 caeser-cipher.py encrypt "Hi, how are you?""` + +### Decrypt + +`python3 caeser-cipher.py decrypt "encryptedtext"` + +For example: `python3 caeser-cipher.py decrypt "hhhhhhhhhh"` diff --git a/Caeser-Cipher/caeser-cipher.py b/Caeser-Cipher/caeser-cipher.py index 81ea07e..222852d 100644 --- a/Caeser-Cipher/caeser-cipher.py +++ b/Caeser-Cipher/caeser-cipher.py @@ -1,4 +1,4 @@ -# Python Caeser Cipher Helper v1.0.1 +# Python Caeser Cipher Helper v1.0.2 # Usage (encrypt): python3 caeser-cipher.py encrypt secretmessage # Usage (decrypt): python3 caeser-cipher.py decrypt secretmessage @@ -14,9 +14,9 @@ from sys import argv # Import tool to process command line arguments. script, action, ciphertext = argv # Take command line input. #ciphertext = input("Please type in your cipher text:") # Set variable cipertext to the input from user. -shiftNum = input("Please enter the shift used (Just hit enter if you don't know):") # Get input +shiftNum = input("Please enter the shift you would like to use (Just hit enter if you don't know the shift used):") # Get input #action = input("Please enter encrypt or decrypt):") # Get input -ciphertext = re.sub (r'([^a-zA-Z ]+?)', '', ciphertext) # Remove all non-letters. +ciphertext = re.sub (r'([^a-zA-Z]+?)', '', ciphertext) # Remove all non-letters. ciphertext = ciphertext.lower() # Make it all lowercase. https://www.geeksforgeeks.org/isupper-islower-lower-upper-python-applications/ letters = list(string.ascii_lowercase) # Use a list of lowercase letters. https://stackoverflow.com/questions/43918437/how-to-iterate-through-the-alphabet letterCount = 0 # Set variable for keeping track of which letter in the ciphertext we're on.