const cypher_index;
char cypherText[] = "LMU XOASR JCZIK VZN EODTUP ZHUC LMU GFWY PZBQ";
char plainText[sizeof(cypherText)];
char cypher[] = {'I', 'G', 'R', 'M', 'J', 'A', 'L', 'V', 'W', 'B', 'N', 'T', 'H', 'X', 'U', 'D', 'S', 'K', 'C', 'P', 'E', 'F', 'Z',
'Q', 'Y', 'O', ' ', '\n', '\0' };
int index(char letter) {
switch (letter)
{
case (' '): return 26;
case ('\n'): return 27;
case ('\0'): return 28;
default: return (int) (letter - 'A');
}
}
void setup() {
Serial.begin(9600);
for (int i = 0; i < sizeof(plainText); i ++) {
plainText[i] = '\0';
}
What I have tried:
I tried to make loop that will examine each character in cypherText and convert the character to its plain text equivalent. The function index returns an integer that you can use to find the plain text letter from the array cypher. it did not work