I am trying to encrypt a string in my Arduino device and send it to server using HTTP POST command.
I used this AES library:
AES Library Arduino
I used this base64 library:
base64
this PHP script:
AES PHP
Code for encryption and then base64 encoding:
#include <AESLib.h>
#include <Base64.h>
void setup() {
Serial.begin(57600);
uint8_t key[] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15};
char data[] = "abcdefghijklmnop"; //16 chars == 16 bytes
aes128_enc_single(key, data);
Serial.print("encrypted:");
Serial.println(data);
// encoding base64 starts here
int inputLen = sizeof(data);
int encodedLen = base64_enc_len(inputLen);
char encoded[encodedLen];
Serial.print(data); Serial.print(" = ");
// note input is consumed in this step: it will be empty afterwards
base64_encode(encoded, data, inputLen);
Serial.println(encoded);
}
void loop() {
// put your main code here, to run repeatedly:
}
after aes encryption and base64 encoding I tried to Decrypt my encoded string in my server using this PHP script but the decrypted result doesn't match with my original data.
I used this PHP AES script,
PHP AES
I am new to Arduino and PHP and trying to solve this problem from last few days. Please help me with this problem.