Questions tagged [vigenere]

Vigenère cipher is an encryption algorithm developed in 1553 and was considered uncrackable until the middle of the 19th century.

Application:

In order to encrypt text, you need to choose a word, W, and the encryption table.

Now, you encrypt the mth letter in the text you want to encrypt using a letter from the word W that was chosen before according to the following formula:

Em = L(m % n)

where:
m — the serial number of the letter n the text
Em — the letter for the m letter in the text
n — the length of w
L — the letter in w in the specified index.

Now, in the encryption table you go to (Em,Tm) (Tm is the m letter you encrypt), and write the letter that's written there, instead of the original letter.

The encryption table

 |a|b|c|d|e|f|g|h|i|j|k|l|m|n|o|p|q|r|s|t|u|v|w|x|y|z|
------------------------------------------------------
a|a|b|c|d|e|f|g|h|i|j|k|l|m|n|o|p|q|r|s|t|u|v|w|x|y|z|
------------------------------------------------------
b|b|c|d|e|f|g|h|i|j|k|l|m|n|o|p|q|r|s|t|u|v|w|x|y|z|a|
------------------------------------------------------
c|c|d|e|f|g|h|i|j|k|l|m|n|o|p|q|r|s|t|u|v|w|x|y|z|a|b|
------------------------------------------------------
d|d|e|f|g|h|i|j|k|l|m|n|o|p|q|r|s|t|u|v|w|x|y|z|a|b|c|
------------------------------------------------------
e|e|f|g|h|i|j|k|l|m|n|o|p|q|r|s|t|u|v|w|x|y|z|a|b|c|d|
------------------------------------------------------
f|f|g|h|i|j|k|l|m|n|o|p|q|r|s|t|u|v|w|x|y|z|a|b|c|d|e|
------------------------------------------------------
g|g|h|i|j|k|l|m|n|o|p|q|r|s|t|u|v|w|x|y|z|a|b|c|d|e|f|
------------------------------------------------------
h|h|i|j|k|l|m|n|o|p|q|r|s|t|u|v|w|x|y|z|a|b|c|d|e|f|g|
------------------------------------------------------
i|i|j|k|l|m|n|o|p|q|r|s|t|u|v|w|x|y|z|a|b|c|d|e|f|g|h|
------------------------------------------------------
j|j|k|l|m|n|o|p|q|r|s|t|u|v|w|x|y|z|a|b|c|d|e|f|g|h|i|
------------------------------------------------------
k|k|l|m|n|o|p|q|r|s|t|u|v|w|x|y|z|a|b|c|d|e|f|g|h|i|j|
------------------------------------------------------
l|l|m|n|o|p|q|r|s|t|u|v|w|x|y|z|a|b|c|d|e|f|g|h|i|j|k|
------------------------------------------------------
m|m|n|o|p|q|r|s|t|u|v|w|x|y|z|a|b|c|d|e|f|g|h|i|j|k|l|
------------------------------------------------------
n|n|o|p|q|r|s|t|u|v|w|x|y|z|a|b|c|d|e|f|g|h|i|j|k|l|m|
------------------------------------------------------
o|o|p|q|r|s|t|u|v|w|x|y|z|a|b|c|d|e|f|g|h|i|j|k|l|m|n|
------------------------------------------------------
p|p|q|r|s|t|u|v|w|x|y|z|a|b|c|d|e|f|g|h|i|j|k|l|m|n|o|
------------------------------------------------------
q|q|r|s|t|u|v|w|x|y|z|a|b|c|d|e|f|g|h|i|j|k|l|m|n|o|p|
------------------------------------------------------
r|r|s|t|u|v|w|x|y|z|a|b|c|d|e|f|g|h|i|j|k|l|m|n|o|p|q|
------------------------------------------------------
s|s|t|u|v|w|x|y|z|a|b|c|d|e|f|g|h|i|j|k|l|m|n|o|p|q|r|
------------------------------------------------------
t|t|u|v|w|x|y|z|a|b|c|d|e|f|g|h|i|j|k|l|m|n|o|p|q|r|s|
------------------------------------------------------
u|u|v|w|x|y|z|a|b|c|d|e|f|g|h|i|j|k|l|m|n|o|p|q|r|s|t|
------------------------------------------------------
v|v|w|x|y|z|a|b|c|d|e|f|g|h|i|j|k|l|m|n|o|p|q|r|s|t|u|
------------------------------------------------------
w|w|x|y|z|a|b|c|d|e|f|g|h|i|j|k|l|m|n|o|p|q|r|s|t|u|v|
------------------------------------------------------
x|x|y|z|a|b|c|d|e|f|g|h|i|j|k|l|m|n|o|p|q|r|s|t|u|v|w|
------------------------------------------------------
y|y|z|a|b|c|d|e|f|g|h|i|j|k|l|m|n|o|p|q|r|s|t|u|v|w|x|
------------------------------------------------------
z|z|a|b|c|d|e|f|g|h|i|j|k|l|m|n|o|p|q|r|s|t|u|v|w|x|y|

More information at Wikipedia under Vigenère cipher.

330 questions
6
votes
1 answer

Confused about Vigenère cipher implementation in Java

Please can someone explain the line of code highlighted below. I don't understand at all how this line works. You can use this example to help me: input: ATTACK keyword: LEMON res: LXFOPV I don't understand how that line helps encode A…
JavaBeginner
  • 105
  • 5
6
votes
3 answers

Where can I find the Java source code for the Vigenere cipher?

in my app I wanted to implement some enciphering. Therefore I need the code for the Vigenere cipher. Does anyone know where I can find that source code for Java?
user1420042
  • 1,619
  • 8
  • 33
  • 51
5
votes
3 answers

Vigenère Cipher Function In Python

After watching this tutorial about the Vigenere Cipher, I (hopefully) understand its basic concepts. We want to assign a key to a string, and then shift each letter in the string by the (0-based) alphabet-position value of each letter in the key. So…
SpeakInCode43
  • 520
  • 2
  • 8
  • 20
4
votes
1 answer

Appending an item to a list with out the [ ] brackets

Im trying to code a Vigenere cipher. I'm building a 2D list that goes [[a,b,c,d], [b,c,d,a], [c,d,a,b], [d,a,b,c]] I have it working except the part im slicing from the front and moving to the back ends up with [ ] brackets. eg. [[a,b,c,d],…
Ari
  • 2,499
  • 2
  • 24
  • 54
4
votes
1 answer

Vigenere Square Lookup (using string arrays)

Vigenere ciphers are supposedly easy to use (well, to some extent), but when converting it directly into program code, that's a whole other story. Apparently. Here's the Vigenere Square: Let's say I have a method that can encrypt text using the…
Kaitlyn
  • 789
  • 10
  • 27
4
votes
1 answer

Vigenère cipher implementation

I have to implement a variant of the Vigenère cipher. I got the encryption part without issues, but I have a bug in the decryption code and I don't understand what I'm doing wrong. The requirements are: the key can only contain A - Z…
user2820314
  • 43
  • 1
  • 4
4
votes
1 answer

Vigenere in PHP

could anyone help me fix this Vigenere cypher in PHP? Sorry for the ripped up code, that's from where I have been dissecting it for hours - trying to fix! Anyhow, the code outputs 'Ace' when it should output 'Abc'. There is some weird double…
Openstar63
  • 159
  • 2
  • 3
  • 7
3
votes
1 answer

Case sensitive Vigenere cipher produces wrong output

I have put a lot of effort into making a cipher more robust so that the output is case sensitive. Meaning, if a capital letter is in the message string, the output will have an encoded capital letter in the string at that location.. For example…
parker_codes
  • 2,514
  • 1
  • 15
  • 23
3
votes
1 answer

vigenere cypher in c++

I've tried to create a c++ program which takes some input and encrypts it using a vignere cypher. my input is: the swift brown fox jumps over the lazy dog which, given the key "hello", outputs this: alpdvpjemqvayqnenfxozsgpqalpwgcozfg which…
3
votes
1 answer

Will this vigenere cipher be possible in Java?

Dismissing Scanner and prompts for the vigenere cipher I have: for(int i = 0; i < text.length(); i++){ int first = text.charAt(i); for(int j = 0; j < key.length(); j++){ int second = key.charAt(j); int that = first + (second…
Kissamer
  • 31
  • 1
3
votes
2 answers

Incrementing and wrapping the key

string text = GetString(); //enters length of argv string into q //converts string argv[1] into string key string key = argv[1]; int klen = strlen(key); int kposition = 0; //loop through the characters in array "text" for (int tposition…
DavidH
  • 31
  • 2
3
votes
2 answers

Vigenere Cipher output

I was looking at the Vigene Ciphere source code provided on http://rosettacode.org/wiki/Vigen%C3%A8re_cipher#Java. I tried testing out the program myself, and it wasn't outputting the values I expect based on vigene. For example 'dog' being the word…
user2982832
  • 177
  • 8
3
votes
2 answers

Randomized Vigenere Cipher with Python

To clarify before beginning: I'm aware there are similar topics, but nothing that has really offered any direct help. Also: this is a class project; so I'm not looking for anyone to code my project for me. Tips and advice is what I'm looking for. (I…
3
votes
3 answers

Vigenère cipher in Java for all UTF-8 characters

I have this simple function for encrypting strings via Vigenère in Java. I omitted the decryption as this is just a "-" instead of the "+" in the line where the new value is calculated. But this function works only for the normal alphabet A-Z. How…
caw
  • 29,212
  • 58
  • 168
  • 279
2
votes
2 answers

Python 3: Generate not all permutations, but all non-repetitive combinations of length r?

I'm trying to generate a lazily iterable collection of Vigenere cipher keys of length r. I'm aware of itertools and the permutations() method. However, this generates keys such as ABCD, ABCE, ABCF... but it will never do something like AABC. So…
2rs2ts
  • 9,020
  • 6
  • 44
  • 80
1
2 3
21 22