FreeBSD Manual Pages
caesarcipher(1) Manpage for caesarcipher caesarcipher(1) NAME caesarcipher - Caesar cipher cryptography tool SYNOPSIS caesarcipher [-d|-e] [-p] [-s shiftvalue] [-i inputfile] [-o output- file] [message ...] DESCRIPTION caesarcipher is an implementation of the Caesar cipher encryption algo- rithm extended to the entire set of printable ASCII characters. Program Invocation: caesarcipher can be invoked in the following three forms: 1st Form: If invoked with no arguments, other than a possible shift- value -s or the -p option, the user is placed into a shell like command line enviroment, in which he can enter messages to be encrypted or de- crypted. The "caesarcipher shell" which identifies itself by: cc> understands the following commands: ascii - print the ASCII table. decrypt - enter a message to decrypt. encrypt - enter a message to encrypt. exit - exit caesarcipher. help - print the command menu. shifttable - print the current shift table. shiftvalue - set a new shiftvalue. spaces - turn preserve spaces on/off. quit - quit caesarcipher (same as exit). 2nd Form: In this form, the utility is invoked with either the -d or -e switch, a given shift value -s to encrypt or decrypt messages passed via the command line. 3rd Form: If the message to be processed is inside a file, then caesar- cipher can, alongside the -d or -e switches, be invoked with the -i option, which takes an associated inputfile argument. If -o outputfile is specified as well, then the encoded/decoded message is written to the outputfile. Otherwise the message is written to stdout. OPTIONS -d, --decrypt decrypt the message or inputfile -e, --encrypt encrypt the message or inputfile -h, --help print a help message and exit -i inputfile, --inputfile=inputfile read from inputfile -o outputfile, --outputfile=outputfile write to outputfile -p, --preserve-spaces preserve spaces when decoding/encoding -s shiftvalue, --shiftvalue=shiftvalue set the shiftvalue THEORY The cipher works by shifting the characters in the original message by a certain number, thus creating a new - encrypted - message. Take for example the letters from A-Z (original alphabet), and another alphabet (shifted alphabet), in which each letter has been shifted by the number 5 (shiftvalue): Original Alphabet: Shifted Alphabet: A F B G C H D I E J F K G L H M I N J O K P L Q M R N S O T P U Q V R W S X T Y U Z V A W B X C Y D Z E Suppose now, that the message to encrypt is: THIS IS THE SECRET MESSAGE By making use of the above table, every character of the original mes- sage can be mapped to its corresponding character in the shifted alpha- bet. The encrypted message therefore becomes: YMNX NX YMJ XJHWJY RJXXFLJ To decrypt a message, knowledge of the shiftvalue (encryption key) is required. Decryption works by reverse shifting (subtracting) the given encryption key from every letter, thus obtaining the original message. Whereas the classical Caesar cipher only uses capital letters from A-Z, as in the example above, this implementation is capable of transforming all displayable ASCII characters (Hex 20 - Hex 7E). Note however, that caesarcipher should not be used for serious encryp- tion purposes, as the algorithm is not inherently safe. The Caesar cipher is named after Julius Caesar (100 BC - 44 BC). EXAMPLES 1. Encode the message: "Secret Message" with a shift value of 21 and write it to stdout. caesarcipher -e -s 21 "Secret Message" 2. Decode the string "123456789" with a shift value of 1. caesarcipher -d -s 1 123456789 3. Encode the contents of file orig.txt with a shift value of -179 and preserve spaces. Write the result to encrypted.txt. caesarcipher -e -s -179 -p -i ~/orig.txt -o ~/encrypted.txt AUTHOR Oliver Mahmoudi (contact@olivermahmoudi.com) caesarcipher 1.1 June 2020 caesarcipher(1)
NAME | SYNOPSIS | DESCRIPTION | OPTIONS | THEORY | EXAMPLES | AUTHOR
Want to link to this manual page? Use this URL:
<https://man.freebsd.org/cgi/man.cgi?query=caesarcipher&sektion=1&manpath=FreeBSD+Ports+15.0>
