[solved] AES & nRf24l01

That's great. Mind sharing the solution so others with the same issue can learn from it?

sterretje:
That's great. Mind sharing the solution so others with the same issue can learn from it?

yes i have update the code in the first page to be used

Generally, changing a post is considered discourteous if it wrecks the following thread.

vaj4088:
Generally, changing a post is considered discourteous if it wrecks the following thread.

so what do u suggest?

Before, you should have left the post alone. Now, you should put the post back the way that it was.

Then, you should post a reply with the updated code that solved your problem.

vaj4088:
Before, you should have left the post alone. Now, you should put the post back the way that it was.

Then, you should post a reply with the updated code that solved your problem.

done

updated code

transmitter code

#include <AESLib.h>
#include <SPI.h>
#include <printf.h>
#include <nRF24L01.h>
#include <RF24_config.h>
#include <RF24.h>

// Funk defines
#define CE_PIN 9
#define CSN_PIN 10

// Funk
// create RF24 radio object using selected CE and CSN pins
RF24 radio(CE_PIN,CSN_PIN);

// Funk
// Pipe Adresse
const uint64_t address = 0xE7E7E7E7E7;


byte key[] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15};
char data3[] = "0123456789012345"; //16 chars == 16 bytes


void setup() {
aes128_enc_single(key, data3);
  Serial.begin(115200);
  //Serial.println(sizeof(myData));

  printf_begin();

  // Funkverbindung
 radio.begin();
 radio.setPALevel(RF24_PA_MIN);
 radio.setChannel(100); //  geht bis 125
 radio.setDataRate(RF24_1MBPS);   // geht bis max. 2MBPS
 //radio.setPayloadSize(32);
 radio.setAutoAck(0);
 radio.enableDynamicPayloads();
 radio.setRetries(15,15);
 radio.openWritingPipe(address);
 radio.printDetails();
 

}



void loop() {
 

 
  Serial.println("encrypted:");
  for(int i=0; i<16; i++) {
    Serial.print(data3[i]);
  }

 
  radio.write(data3, sizeof(data3));
 
}

receiver code

#include <SPI.h>
#include <printf.h>
#include <nRF24L01.h>
#include <RF24_config.h>
#include <RF24.h>
#include <AESLib.h>


// Funk defines
#define CE_PIN 9
#define CSN_PIN 10

byte key[] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15};
char data3[16];

// Funk
// create RF24 radio object using selected CE and CSN pins
RF24 radio(CE_PIN,CSN_PIN);


// Funk
// Pipe Adresse
const uint64_t address = 0xE7E7E7E7E7;



void setup() {
  Serial.begin(115200);   //Starten der seriellen Kommunikation mit 9600 baud

  // Wird benötigt für die printDetails Funktion
  printf_begin();

  // Funkverbindung
 radio.begin();
 radio.setPALevel(RF24_PA_MIN);
 radio.setChannel(100); //  geht bis 125
 radio.setDataRate(RF24_1MBPS);
 //radio.setPayloadSize(32);
 radio.setAutoAck(0);
 radio.enableDynamicPayloads();
 radio.openReadingPipe(1,address);
 radio.printDetails();

   radio.startListening();
 
 }

void loop() {

  if (radio.available()) {
 
    radio.read(data3, sizeof(data3));
   
aes128_dec_single(key, data3);
   
 
 
       
   
  }
 Serial.println("Decrypted");
    for(int i=0; i<16; i++) {
    Serial.print(data3[i]);
  }

}
1 Like