I am trying to simulate a brute force attack using an additive cipher and i need to use modulus on some numbers but when i try to use the modulus operator "%" it never seems work here is my code
#include <cstdlib>
#include <iostream>
using namespace std;
int main()
{
char cipherText [15] = "UOISCXEWLOBDOX";
char guess [] = " ";
int numArray [15];
int modArray [15];
int finalArray[15];
char alpha [26] = {'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'};
//Get Number for each letter
for(int x = 0; x < sizeof(cipherText); x++)
{
char c = cipherText[x];
int num = 0;
for(int i = 0; i<sizeof(alpha);i++)
{
if(c == alpha[i])
{
num = num + 0;
break;
}
else
{
num = num + 1;
}
}
numArray[x] = num;
//cout<<" "<<numArray[x];
}
for(int i = 0; i < 26; i++)
{
cout<<endl;
for(int x = 0; x < 15; x++)
{
int j;
if(i == 0)
{
j = numArray[x];
}
else
{
j = numArray[x]-i;
}
modArray[x] = j;
//cout<<modArray[x]<<" ";
}
for(int x = 0; x < 15; x++)
{
int y = (modArray[x])%26;
cout<<modArray[x]<<" ";
}
cout<<endl;
}
}
the output stays as the array of numbers minus i. i dont know why this isnt working any help would be appriciated.