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

Homemade Vigenere cipher; working with acsii character manipulation

As the post title suggests, I'm working to strengthen my grasp on C++ and character manipulation, this time through creating a Vigenere Cipher. For those unfamiliar with it, it's a fairly simple way to encrypt a text file. The basic way it works is…
Joshua
  • 4,270
  • 10
  • 42
  • 62
0
votes
1 answer

Breaking a Modified Vigenere Cipher

Im working on an algorithm to break a modified Vigenere Cipher. The regular Vigenere cipher works in the following way: Plaintext: ATTACKATDAWN Key: LEMONLEMONLE Ciphertext: LXFOPVEFRNHR Regular Version CR[i] = (P[i] - 33 + K[i]) mod 94 +…
1337holiday
  • 1,924
  • 1
  • 24
  • 42
0
votes
1 answer

encrypting a Document using vigenere cipher

I'm interested in learning about different encryption techniques and have started to implement a vigenere cipher in c#. I can implement a windows forms which allows me to encrypt and decrypt a string similar the following…
user1849946
  • 19
  • 1
  • 5
0
votes
1 answer

Encrypt byte array using vigenere cipher in java

I have to encrypt some file (jpg) using vigenere cipher. I wrote some code, but after encryption and decryption my file is corrupted. The first 1/4 of image displays okay, but the rest of it is corrupted. Here is my code: @Override public byte[]…
Maniek
  • 1,293
  • 1
  • 9
  • 9
0
votes
1 answer

Math operation trouble

This might seem like a very simple solution to some people but I have been trying to figure it out for a while now and its bugging me. int sum = (p[i] - 'A') + (s2[i % keyLen] - 'A'); char c = 'A' + sum%26; I am having trouble coming up with the…
Yamaha32088
  • 4,125
  • 9
  • 46
  • 97
-1
votes
1 answer

Vigenere Cipher Algorithm In Java - Decrypted Message to Plaintext

I am currently trying to write the Vigenere Cipher algorithm in Java. I have to change the decrypted message to the plaintext but having trouble. Below is what I have so far. When I run it, the message is not deciphered properly. import…
-1
votes
1 answer

C++ function for vigenere cipher only sometimes working (works for some inputs, skips shifts for others)

For an in class assignment I had to write a function that puts a user input string through the vigenere cipher with the optional help from helper function. I was able to reach a partial solution using a helper function that gets the correct shift…
exef
  • 31
  • 1
  • 3
-1
votes
1 answer

Why am I getting a type error in my code?

I am trying to write a vigenere cipher code. My psuedo for this is : - find the index for each letter in plaintext - find the index for each letter in the key message - add together the indexes - new letters will be at the position of the sum of…
ajn
  • 11
  • 3
-1
votes
8 answers

Removing all spaces, punctuation, and capitalization

We are working on the Vigenere cipher in my computer science class and one of the first steps our teacher wants us to take is to delete all whitespace, punctuation, and capitalization from a string. #pre-process - removing spaces, punctuation, and…
user11233951
-1
votes
1 answer

CS50 Vigènere problem. Out of bounds access, undefined behavior

So the this is the solution i came with for the CS50 Vigenère problem; I'm fairly new to programming, like only a few weeks so i'm sorry in advance for the form of my code. The problem here is that the output isn't what i expect it to…
-1
votes
1 answer

Vigenere failed test :( encrypts "BaRFoo" as "CaQGon" using "BaZ" as keyword

Can someone help me with my code to solve this error above?I have searched for answers but they are bit different from my code. vigenere.c compiles. encrypts "a" as "a" using "a" as keyword encrypts "barfoo" as "caqgon" using "baz" as…
hobo
  • 3
  • 1
-1
votes
2 answers

Vigénere Cipher in C

#include #include // strlen() #include // isupper() , tolower() void vigenereCipher(char* plainText, char* key); int main(int argc, char argv[]) { char* key = argv[1]; char plainText[101]; // Ask the…
-1
votes
1 answer

How to ignore spaces in Vigenere cipher code?

I have two functions: function EnCryptSymbolVij(text, key:char; abc:string):char; var st: string; positionText: word; begin if text=' ' then begin EnCryptSymbolVij:=' '; exit; end; PositionText:=pos(text,abc); if positionText=0 then exit; …
-1
votes
1 answer

How do I fix the looping from 'z' back to 'a' in my Vigenere Cipher

My Vigenere cipher has problems. When I input my message, the result comes out fine, but if the letter goes past 'z', it doesn't loop back to 'a', and is printing out other ascii characters. Moreover, when I put the message in, I sometimes get more…
Byron
  • 1
  • 1
-1
votes
1 answer

Vigenere how to stop incrementation

#include #include #include #include int main(int argc, string argv[]) { //string for chiper text char s[100]; //exit if no argument or more than one if( argc != 2 ) { …