oh wow, you had the key by chance and the code let you down....the fickle hand of fate! bad news..
Why did your method stop at fffff? Surely it should have gone right to zzzzz? The key could have been zebra…
the brute force could certainly have worked to reveal the key as i had already let you know it was a normal English word of 5 character length, generating each and every combination of five letters then testing each one against the whole or part of the ciphertext as a key would have “eventually..” got you the right key... cycling through everything right up to zzzzz would have been more combinations than you could shake the proverbial stick at of course... knwing it was english word of 5 letters made this a viable option given enough time, no way brute force an efficient or "good" option if no idea of the key length or nature though...
Here is the part of my program that did the encryption, it was rough n ready just to get the job done >
Code:
sourcetext.open("babbage.txt"); //source
sourcegrid.open("vigniere.txt"); //vignere table
cipherdoc.open("cipherdoc.txt"); //output file for the cipher
for(count = 0; count < FILELEN; count++)
{
sourcetext >> sourcedoc[count]; //write an array with the contents of sourcetext
printf("%c", sourcedoc[count]);
if(eol == 50)
{
printf("\n");
eol = 0;
}
else
eol++;
}
printf("\n");
eol = 0;
for(dwn = 0; dwn < 27; dwn++) //fill an array with the vignere table
{
for(acr = 0; acr < 27; acr++)
{
sourcegrid >> alphagrid[dwn][acr];
}
}
sourcetext.close();
sourcegrid.close();
//use vignere table to encrypt //
for(sourcecount = 0; sourcecount < FILELEN; sourcecount++)
{
switch(keycount) //this references the keyword chars as
{ //indexed positions in the vignere table array
case 0:
keyindex = 2;
break;
case 1:
keyindex = 1;
break;
case 2:
keyindex = 19;
break;
case 3:
keyindex = 9;
break;
case 4:
keyindex = 3;
break;
}
//go through the alphabet
for(sourceindex = 0; sourceindex < 27; sourceindex++)
{
//if the alphabet letter matches the current character in the source text
if(alphagrid[0][sourceindex] == sourcedoc[sourcecount])
{
//use the table to find the appropriate encrypted letter
ciphertext[sourcecount] = alphagrid[keyindex][sourceindex];
cipherdoc << ciphertext[sourcecount];// write the cipherletter to the output file
printf("%c",ciphertext[sourcecount]);
sourceindex = 27; //break loop as letter is encrypted
eol++;
}
if(eol > 50)
{
printf("\n");
eol = 0;
}
}
if(keycount == 4)
{
keycount = 0;
}
else
keycount++;
}
printf("\n\n");
cipherdoc.close();
eol = 0;
keycount = 0;