User:Carlondrea/sandbox

=Unraveling the Caesar Cipher=

Background
The Caesar Cipher is named after Julius Caesar who used it with a shift of three to protect his messages of military importance. If he had anything private to say he wrote it in cipher, by changing the order of the letters in the alphabet. Overtime, many realized the Caesar Cipher is very simple and comprehensible. There are levels of ciphering.

Introduction
The Caesar Cipher, also known as a shift cipher, is one of the oldest and simplest forms of encrypting a message. To encrypt a message, each letter of the original message,known as the plaintext, is replaced with a letter corresponding to the key. The key will shift the letters of the plaintext up or down in the alphabet.

For example, you would take a letter's position in the alphabet, say 5 for the letter 'E', and shift it by the key number. If we had a key of +4, that 'E' would be shifted down to an 'I' - and that same process would be applied to every letter in the plaintext.

Procedure
1. Download python or use an online python compiler.

2. Define "ROTX" function with parameters: word, n, and decrypt. def ROTX(word, n, decrypt): The plaintext is the message being encrypted or decrypted, the key is the keyword being used to encrypt or decrypt the message, and the mode indicates whether the plaintext is being encrypted or decrypted. 3. Create a variable that holds a string of all the letters in the alphabet and a variable that holds an empty string and will eventually hold the return cipher. 4. Create an if statement that will decrypt the plaintext if the key is negative or else encrypt the plaintext if the key is positive. If mult =1 the loop will iterate through every letter in word and find the letter's index (position in the alphabet string). If mult= -1 the code works in the opposite way of the encryptor because it’s decrypting. The code takes the index of each letter in the key stream and the corresponding letter in the word (in this case the word will be a string of what looks like random letters.) Then, the index of the letter in the word is subtracted from that of the position. By multiplying n and using modulus 26 the code ensures that the resulting difference is negative it will be brought back into range. Out must be a string and be returned to store the information before it 6. Create a string called input, within that variable call the function input, so when the code runs a word can be inserted. Then print the function you defined earlier with the parameters you want Input will always be a parameter.The second parameter must be a number, which will shift left or right based on the third parameter. The third parameter must be True OR False. False means the word will encrypt, True means the word will decrypt.

Results
Graphs can be based on cipher patterns that occur. Frequency analysis.

Example of a Frequency Analysis
1 Frequency analysis is the study of letters or groups of letters contained in a ciphertext in an attempt to partially reveal the message. The English language (as well as most other languages) have certain letters and groups of letters appear in varying frequencies. This is a chart of the frequency distribution of letters in the English alphabet. As you can see, the letter ‘e’ is the most common, followed by ‘t’ and ‘a’, with ‘j’, ‘q’, ‘x’, and ‘z’ being very uncommon.



Discussion
Results in word form

Conclusion
World implication Future plans How to improve/ change the project

Helpful Tips
Write out the code before using programming language