Programming Encryption Algorithms
Computer Science (Caesar Cipher & Vigenere Cipher)
Encryption is the process of converting a plain text message into cipher text which can be decoded back into the original message. While security is an afterthought for many PC users, it’s a major priority for businesses of any size. Encryption is a way to keep your data safe. There are many different encryption algorithms being used today, some of the most regularly used are RSA, Triple DES, Blowfish, and AES. Two of the simplest and most widely known encryption techniques are Caesar Cipher, and Vignere Cipher. The two encryption methods we will focus on in this article are the Caesar Cipher, and Vignere Cipher algorithms.
The Caesar cipher is a type of substitution encryption. It is considered one of the easiest algorithms to implement. It was used by and is named after Julius Caesar. This cipher is however easily broken through different techniques such as frequency analysis.
Substitution encryption is a type of encryption where some letter is replaced by another letter some constant number away.
Lets say I want to send a secret message to someone, so I encrypt it using Caesar Cipher.
For instance, below I have an encrypted message using Caesar cipher and a right rotation of twenty three places, or equivalently a left shift of 3 (the “shift”/ “rotation” parameter is called the “key”):
Once encrypted, the message becomes slightly unreadable. But, equipped with the secret pass code or “key” I text the sender, s/he can decrypt it and get the original message:key = 3
So the key was a left shift of 3 or equivalently a right shift of 23. You can see what that looks like for the alphabet below for the matching characters.
Plain Text: ABCDEFGHIJKLMNOPQRSTUVWXYZ
Cipher Text: XYZABCDEFGHIJKLMNOPQRSTUVW
Here is a video on programming this algorithm using the C — Programming language. You can use this video to create your own encrypted text.
Get the code here: https://github.com/randerson112358/C-Programs/blob/master/caesarCipher1.c
The Vigenère cipher is a form of polyalphabetic substitution. It is an algorithm of encrypting alphabetic text (e.g. “a” , “b”, “c” etc) by using a series of interwoven Caesar ciphers based on the letters of a keyword. Although Giovan Battista Bellaso had invented the cipher, the Vigenère cipher is named after Blaise de Vigenère.
Polyalphabetic cipher is any cipher based on substitution, using multiple substitution alphabets. Vigenere Cipher is an example of this. A more complex example is the Enigma machine.
Lets say I want to send a secret message to someone, so I encrypt it using Vigenere Cipher.
For instance, below I have an encrypted message using the Vigenere Cipher and a key = “ABCD”
CSASTP KV SIQUT GQU CSASTPIUAQJB
Once encrypted, the message becomes slightly unreadable. But, equipped with the secret pass code or “key” I text the sender, s/he can decrypt it and get the original message:key = “ABCD”
CRYPTO IS SHORT FOR CRYPTOGRAPHY
So the key was “ABCD”. You can see what that looks like for the alphabet below for the matching characters.
Vigenere Cipher C Program video.
Learning how these cyphers work can help your understanding of other encryption methods, but I wouldn’t use them if there was something confidential that I wanted to keep away from everyone else, accept maybe a in class love letter. Thanks for reading and I hope you enjoyed this article. Be sure to check out my videos on programming and computer science on YouTube !