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.

348 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
  • 6
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,689
  • 9
  • 35
  • 53
5
votes
2 answers

Breaking Vigenere only knowing key length

Problem I want to decode a message encrypted with classic Viginere. I know that the key has a length of exactly 6 characters. The message…
Ollie Jones
  • 55
  • 1
  • 5
5
votes
4 answers

Vigenère Cipher function implementation

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
  • 580
  • 4
  • 11
  • 23
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
  • 5,301
  • 8
  • 46
  • 120
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
  • 791
  • 1
  • 10
  • 28
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
  • 3,267
  • 1
  • 19
  • 27
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
  • 9
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
  • 30,999
  • 61
  • 181
  • 291
1
2 3
23 24