A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://TheAlgorithms.github.io/C-Plus-Plus/dd/d12/vigenere__cipher_8cpp.html below:

TheAlgorithms/C++: ciphers/vigenere_cipher.cpp File Reference

Implementation of Vigenère cipher algorithm.

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,

\[ 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,

\[ 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.

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}|\))
This program implements Vigenère cipher for only uppercase English alphabet characters (i.e. A-Z).

Definition in file vigenere_cipher.cpp.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4