const char* hexi[] = {
"41", "42", "43", "44", "45", "46", "47", "48",
"49", "4A", "4B", "4C", "4D", "4E", "4F", "50",
"51", "52", "53", "54", "55", "56", "57", "58",
"59", "5A", "61", "62", "63", "64", "65", "66",
"67", "68", "69", "6A", "6B", "6C", "6D", "6E",
"6F", "70", "71", "72", "73", "74", "75", "76",
"77", "78", "79", "7A", "20" ,"22" ,"27" ,"3A", "3B", "2C", "2E"
};
const char* alpha[] = {
"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", "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", " ", "\"", "'", ":", ";", ",", "."
};
const int hexiCount = sizeof(hexi) / sizeof(hexi[0]);
char text[] = "52 6F 73 65 73 20 61 72 65 20 72 65 64 2C 20 76 69 6F 6C 65 74 73 20 61 72 65 20 62 6C 75 65 2C 20 69 66 20 79 6F 75 27 72 65 20 72 65 61 64 69 6E 67 20 74 68 69 73 2C 20 79 6F 75 72 20 63 6F 64 65 20 70 75 6C 6C 73 20 74 68 72 6F 75 67 68 2E";
void setup() {
Serial.begin(115200);
char *token = strtok(text, " ");
bool foundAny = false;
while (token != NULL) {
bool found = false;
for (int i = 0; i < hexiCount; i++) {
if (strcmp(token, hexi[i]) == 0) {
Serial.print(alpha[i]);
found = true;
foundAny = true;
break;
}
}
if (!found) {
Serial.print("Not found hex byte: ");
Serial.println(token);
}
token = strtok(NULL, " ");
}
if (!foundAny) {
Serial.println("No hex bytes found.");
}
}
void loop() {
// nothing here
}
//previous code v
// const char* hexi[] = {
// "41", "42", "43", "44", "45", "46", "47", "48",
// "49", "4A", "4B", "4C", "4D", "4E", "4F", "50",
// "51", "52", "53", "54", "55", "56", "57", "58",
// "59", "5A", "61", "62", "63", "64", "65", "66",
// "67", "68", "69", "6A", "6B", "6C", "6D", "6E",
// "6F", "70", "71", "72", "73", "74", "75", "76",
// "77", "78", "7A", "20"
// };
// const int hexiCount = sizeof(hexi) / sizeof(hexi[0]);
// const char text[] = {"68 65 6C 6C 6F 20 77 6F 72 6C 64"};
// int length = strlen(text);
// void setup() {
// // put your setup code here, to run once:
// Serial.begin(115200);
// bool found = false;
// for (int i = 0; i < hexiCount; i++) {
// if (strstr(text, hexi[i]) != NULL) {
// Serial.print("Found: ");
// Serial.println(hexi[i]);
// found = true;
// }
// }
// if (!found) {
// Serial.println("No hexi words found.");
// }
// }
// void loop() {
// // put your main code here, to run repeatedly:
// delay(10); // this speeds up the simulation
// }