1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
|
char* makeCypher(int shiftVal)
{
char alphabet[27] = {97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108,
109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, '/0'};
char cypherBet[27];
int loopNum;
cout << "The plain text alphabet is: \n";
for(int g = 0; g < 26; g++)
{
cout << alphabet[g];
}
cout << endl;
cout << "This is the Cypertext alphabet: \n";
for(int h = 0; h < alphabet[h] && alphabet[h] != '/0'; h++)
{
if((alphabet[h] +shiftVal) > 122)
{
loopNum = ((alphabet[h]+shiftVal)-122);
cypherBet[h] = alphabet[loopNum-1];
}
else
{
cypherBet[h] = alphabet[h] + shiftVal;
}
cout << cypherBet[h];
}
cout<<endl;
return cypherBet;
}
|