Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "Base64.h"
- #include <AESLib.h>
- #include <ESP11.h>
- ESP11 wifi = ESP11();
- char lorem[3005];
- void serialSetup(){
- Serial.begin(115200);
- Serial.println(F("READY, AES, delay-time-chunks, RECEIVER"));
- do {
- delay(250);
- }while(Serial.available() <= 0);
- }
- void remove_padding(char* data, int len) {
- //16 - length % 16
- int done = 0;
- while(!done){
- len--;
- if(data[len] == (char)0x80){
- data[len] = '\0';
- }else {
- done = 1;
- }
- }
- }
- void aes128dec(char data[]) {
- uint8_t key[] = "1234567890123456";
- char* pointer = data;
- int baselen = strlen(data);
- for(int from = 0; from < baselen; from += 16) {
- char dest[32];
- strncpy(dest, pointer+from, 16);
- aes128_dec_single(key, dest);
- if((baselen-from) <= 16) {
- remove_padding(dest, 16);
- }
- dest[16] = '\0';
- Serial.println(dest);
- }
- }
- void setup() {
- serialSetup();
- wifi.reset();
- wifi.stationMode();
- wifi.connect(F("THESIS99"), "");
- wifi.sendData("AT+CIPMUX=1",2000, "");
- wifi.sendData("AT+CIPSERVER=1,80",2000, "OK");
- wifi.sendData("AT+CIFSR",2000, "");
- Serial.println("READY");
- }
- void loop() {
- String encodedStr = wifi.receivedata();
- if(encodedStr.length() != 0){
- int decodedLen = base64_dec_len((char *)encodedStr.c_str(), encodedStr.length());
- char data[decodedLen];
- base64_decode(data, (char*)encodedStr.c_str(), encodedStr.length());
- // aes128dec(data);
- wifi.flush();
- Serial.println("Done");
- // wifi.close();
- }
- delay(250);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement