diff --git a/dd/d12/vigenere__cipher_8cpp.html b/dd/d12/vigenere__cipher_8cpp.html index 173b19ab0..bb6c798f9 100644 --- a/dd/d12/vigenere__cipher_8cpp.html +++ b/dd/d12/vigenere__cipher_8cpp.html @@ -135,15 +135,15 @@ Functions

The Vigenère cipher is a method of encrypting alphabetic text by using a series of interwoven vigenere ciphers, based on the letters of a keyword. It employs a form of polyalphabetic substitution.

Algorithm

-

The encryption can also be represented using modular arithmetic by first transforming the letters into numbers, according to the scheme, A → 0, B → 1, ..., Z → 25. Encryption of \(\i^{th}\) character in Message M by key K can be described mathematically as,

+

The encryption can also be represented using modular arithmetic by first transforming the letters into numbers, according to the scheme, A → 0, B → 1, ..., Z → 25. Encryption of \(i^{th}\) character in Message M by key K can be described mathematically as,

\[ E_{K}(M_{i}) = (M_{i} + K_{i})\;\mbox{mod}\; 26\]

-

while decryption of \(\i^{th}\) character in Cipher C by key K can be described mathematically as,

+

while decryption of \(i^{th}\) character in Cipher C by key K can be described mathematically as,

\[ D_{k}(C_{i}) = (C_{i} - K_{i} + 26)\;\mbox{mod}\; 26\]

-

Where \(\K_{i}\) denotes corresponding character in key. If \(\|key| < |text|\) than same key is repeated untill their lengths are equal.

+

Where \(K_{i}\) denotes corresponding character in key. If \(|key| < |text|\) than same key is repeated untill their lengths are equal.

For Example, If M = "ATTACKATDAWN" and K = "LEMON" than K becomes "LEMONLEMONLE".

Note
Rather than creating new key of equal length this program does this by using modular index for key (i.e. \((j + 1) \;\mbox{mod}\; |\mbox{key}|\))