This code takes two arguments from the command line: a string of text to encrypt and the number of positions to shift each letter by. The program then encrypts the text using the Caesar Cipher method and prints the result to the console. The encrypted text is printed in blocks of five letters and a maximun of 10 blocks per line.
This cipher is a type of substitution cipher. The idea of a Caesar cipher is this: you encode a message by shifting each letter some number of places. Thus, if the shift is 2, then A becomes C, B becomes D, and so on. Like this:
-
Clone the repository:
git clone https://github.com/luminaa/github-lab
-
Then go to the file directory:
cd ./github-lab
-
To use
caesar.py
, run it from the command line and provide the string to encrypt and the number of positions to shift as arguments. For example:python caesar.py "Encrypt this text" 3
The above command will encrypt the string "Encrypt this text" using a shift of 3 and print the encrypted result to the console. This would be "HQFUB SWWKL VWHAW"
-
Alternatively, you can use the bash script
caesar.sh
. (THIS ONLY WORKS FOR LINUX AND MAC) First, you have to make it executable. Run the following command in your shell.chmod +x caesar.sh
After that, you can run the script by typing the following command:
./caesar.sh