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
-1
votes
1 answer

How do I repeat a 'for' loop using a 'do while' loop

This is my Vigenere Cipher code. I'm trying to use the do while loop to repeat the iteration over the key entered by the user. The key is applied to the plaintext word entered by the user, one letter at a time. I need to be able to iterate over the…
Android
  • 11
  • 8
-1
votes
1 answer

Vigenere Cipher. Code output

I've been working on cs50 pset2, and I thought I had the vigenere cipher down after working on it for a few days. This code is meant to take an alphabetical argument(argv[]) given by the user, and use that as a key to crypt a phrase given by the…
-1
votes
1 answer

Got stuck in the final part of a program for encryption in Vigenere

I am attending the online course cs50 on Edx and I have an assignment in which I have to create a program where the user enters a keyword ( used then for encryption ) and a string that needs to be encrypted in Vigenere cipher. Vigenere works by…
-1
votes
2 answers

Multi-character character constant error

I am creating a program that enciphers text using the vigenere cipher. However, when ever I run the code, it gives me errors saying vigenere.c:27:29: error: multi-character character constant [-Werror,-Wmultichar] int letternum =…
-1
votes
1 answer

Vigenere Cipher only works up until dealing with a space(" ") in C - why?

#include #include #include #include #include int main(int argc, string argv[]) { string k = argv[1]; string s = GetString(); int l = strlen(k); for(int i = 0, n =…
HakBon
  • 63
  • 1
  • 9
-1
votes
1 answer

IndexError: list index out of range error in python

I'm writing a vigenere cipher for a personal project and i am coming across a index error. it is saying IndexError: list index out of range. The line causing this is IndexValue = Alphabet.index(keyList[keyIncrement]) +…
-1
votes
1 answer

How do i force my code to print in python

I'm having trouble trying to work out an error in my code. It isn't printing the final product and leaving a blank space. playing = True string = "" Alphabet = ('z','a','b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q',…
xxowainxx
  • 1
  • 4
-1
votes
2 answers

Can someone tell me why my encrpyt works but not my decrpyt? look at picture below

#Vigenere Cipher EncryptedMessage="" Mode="" Keywordcount = 0 #sets everything to 0 while Mode != "encrypt" and Mode != "decrypt": Mode = input('Do you want to encrypt or decrypt a message?') Mode = Mode.lower() if Mode ==…
-1
votes
2 answers

Adding certain numbers together in a string/list then turning then into letters

Currently doing a Vigenere cipher in Python, and me and many people in my class are stuck on one aspect. After we translated the keyword to ordinals, we need to add those number to a message to encrypt it. This is my code so far. Input =…
-1
votes
1 answer

encrypting upper-case letters python vigenere

I'm having trouble encrypting upper-case letters e.g. if the message is COMPUTING IS FUN the keyword is GCSE i should get JRFUBWBSN LL KBQ but my actual result is xftipkpgb zz ype. This result neither has the correct letters nor is capital. Any help…
MrBeard
  • 23
  • 7
-1
votes
1 answer

Vigenere's Cipher in C (CS50)

I have been stuck on this for a while now, I thought I had it working several times only to find more things I forgot. Basically the problem set was to create the Vigenere Cipher using C, the rules can be found here I basically have it working it…
-1
votes
2 answers

CS50 pset2 Vigenere code - Outputs one incorrect letter

New to this site and to programming. I've looked through the previous questions under this topic and tried any number of fixes, but I keep having the same problem. My program runs fine and gives me the output I expect, with the exception of the…
jmg414
  • 1
  • 2
-1
votes
1 answer

vigenere cipher - not adding correct values

I want to get specific values from a for loop to add to another string to create a vigenere cipher. here's the code. userinput = input('enter message') keyword = input('enter keyword') new = '' for a in keyword: pass for i in (ord(x) for x in…
MrBeard
  • 23
  • 7
-1
votes
1 answer

Vigenere cipher difficulties

This is a Vigenere cypher for cs50. It's my first time coding and I'm going around this for a week now, and I don't seem to be able to print first letter after the loop finishes for the first time. For example: jharvard@appliance (~/Dropbox):…
-1
votes
1 answer

Vigenere fails check50 test encrypts “BaRFoo” as “CaQGon” using “BaZ” error in C

Vigenere fails check50 test encrypts "BaRFoo" as "CaQGon" using "BaZ" >error, my program output is "caQGoh". I don't know what's the problem but i guess that this problem apears when there are different letter cases(lowercase and uppercase)plus…
Paul KH
  • 1
  • 2