Vernam Cipher in Swift

Unbreakable encryption is possible. Welcome to One-time Pad or what also referred to as “the perfect cipher”. To be honest, it is comforting to know that it is possible to encrypt text conversations to the point where it is practically impossible to decrypt without having the correct key. While the previous two ciphers mentioned earlier (Caesar Cipher and Vigenere Cipher) provide a way to scramble text into “gibberish”, both can be easily decrypted using pattern matching without needing the original key.

Unlike previous crypto algorithms, Vernam uses random key composed of random numbers to encrypt text. It is a very simple, yet powerful algorithm as you will see shortly.

Continue reading “Vernam Cipher in Swift”

Vernam Cipher in Swift

Vigenere Cipher in Swift

Here is another classic cipher in Swift. This time it’s Vigenere. Similar to the way Caesar cipher works, Vigenere cipher improves on a couple of things. If you can recall my previous article, Caesar cipher works by shifting each letter in the plaintext a certain number of places down the alphabet. Vigenere cipher tries to improve on that approach by utilizing the keyword to offset each plain text letter by the keyword letter. This, of course, requires the keyword to be of the same length as the plain text.

Continue reading “Vigenere Cipher in Swift”

Vigenere Cipher in Swift