Hi Danois, thanks! This is the direction i wanna take.
I was trying the code you sent, which works fine, but what i want to crypt is something i will read and send to the function. I have made this:
char* key = "secret";
void xor_crypt(char *buffer, int buf_len, char* key, int key_len)
{
int ki = 0;
for (int bi = 0; bi < buf_len; bi++) {
buffer[bi] ^= key[ki++];
if (ki >= key_len) ki = 0;
}
}
void crypt(char * input) {
xor_crypt(input, strlen(input), key, strlen(key));
Serial.println(input);
xor_crypt(input, strlen(input), key, strlen(key));
Serial.println(input);
delay(5000);
}
What happens now is that when i pass the text i want to crypt, when i then decrypt it, it doesn't show all the text 
Danois90:
There are AES libraries for Arduino / ESP8266 which can do the job - but they introduce a performance and storage impact. You could use some very basic bit inversion instead:
void xor_crypt(char *buffer, int buf_len, char* key, int key_len)
{
int ki = 0;
for (int bi = 0; bi < buf_len; bi++)
{
buffer[bi] ^= key[ki++];
if (ki >= key_len) ki = 0;
}
}
...
char* key = "secret";
char* str = "Say hello to my little friend!";
//Encrypt
xor_crypt(str, strlen(str), key, strlen(key));
Serial.println(str); //This will be "garbage" in the serial monitor
//Reverse
xor_crypt(str, strlen(str), key, strlen(key));
Serial.println(str); //This will be the original string again
Even though this form of encryption may seem crude, it may be just as hard to break as more advanced forms of encryption - but the performance impact is negligible.