LCD+ Wireless Radio Transmitter+encryption/decryption

help me please witch decryption text.
i have two arduino.
First was transmit and the second is receiver.
I realized

transmit-->>encryption-->>send-->>recive(encrypted)-->>decryption-->>Send to Screen Receiver

remains only decryption.
function aes128_dec_single(key, data);
but I can not understand how to get full buf for use aes128_dec_single(key, data);

Thank you in advance for your help..

transmit

#include <VirtualWire.h>
#include <AESLib.h>

void setup()
{

  vw_setup(2000);   // Bits per sec
}



void loop()
{
  Serial.begin(57600);
  uint8_t key[] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15};
  char msg[] = "testtesttesttest";
  aes128_enc_single(key, msg);
  
  vw_send((uint8_t *)msg, 16);
  vw_wait_tx(); // Wait until the whole message is gone
 
  delay(1000);
 }

receiver

#include <VirtualWire.h>
#include <Wire.h> 
#include <LiquidCrystal_I2C.h>
#include <AESLib.h>

// Set the LCD address to 0x27 for a 16 chars and 2 line display
LiquidCrystal_I2C lcd(0x27, 16, 2);


void setup()
{
    delay(1000);
      
  lcd.begin();

  
  lcd.backlight();
    vw_setup(2000);  

    vw_rx_start();       // Start the receiver PLL running
}

void loop()
{
  Serial.begin(57600);
  uint8_t key[] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15};
    uint8_t buf[VW_MAX_MESSAGE_LEN];
    uint8_t buflen = VW_MAX_MESSAGE_LEN;

    if (vw_get_message(buf, &buflen)) // Non-blocking
    {
     
  int i;
   lcd.clear();
   
 
  
  Serial.print("Got: ");
  lcd.print("Got: ");
  
  for (i = 0; i < buflen; i++)
  {
     Serial.write(buf[i]);
     
        lcd.write(buf[i]);
        
  }
Serial.println();

     
    }
    delay(1000);
    lcd.clear();
    lcd.print("wait ");
}

but I can not understand how to get full buf[ i ]

buf[ i ] is ONE element of the array. buf is the whole array. You get that here:

   if (vw_get_message(buf, &buflen)) // Non-blocking

VirtualWire will receive a message of the same length as the message you send.
You may need to change the default buffer size in VirtualWire.

how to get the entire array ? buf
then I just do aes128_dec_single(key, data);

I got full buf , only for output to Screen but not for use
Serial.write(buf,16);

Serial.write(buf,16);

That statement writes 16 bytes.

You will have to do a better job of explaining the problem you are having.

if I use

aes128_dec_single(key, buf);
Serial.print("decrypted:");
Serial.write(buf);

i have many errors

reciwedec.ino: In function 'void loop()':
reciwedec:37: error: call of overloaded 'write(uint8_t [30])' is ambiguous
reciwedec.ino:37:17: note: candidates are:
In file included from C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Arduino.h:224:0,
                 from C:\Program Files (x86)\Arduino\libraries\VirtualWire/VirtualWire.h:146,
                 from reciwedec.ino:1:
C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/HardwareSerial.h:124:20: note: virtual size_t HardwareSerial::write(uint8_t) <near match>
     virtual size_t write(uint8_t);
                    ^
C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/HardwareSerial.h:124:20: note:   no known conversion for argument 1 from 'uint8_t [30] {aka unsigned char [30]}' to 'uint8_t {aka unsigned char}'
C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/HardwareSerial.h:125:19: note: size_t HardwareSerial::write(long unsigned int) <near match>
     inline size_t write(unsigned long n) { return write((uint8_t)n); }
                   ^
C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/HardwareSerial.h:125:19: note:   no known conversion for argument 1 from 'uint8_t [30] {aka unsigned char [30]}' to 'long unsigned int'
C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/HardwareSerial.h:126:19: note: size_t HardwareSerial::write(long int) <near match>
     inline size_t write(long n) { return write((uint8_t)n); }
                   ^
C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/HardwareSerial.h:126:19: note:   no known conversion for argument 1 from 'uint8_t [30] {aka unsigned char [30]}' to 'long int'
C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/HardwareSerial.h:127:19: note: size_t HardwareSerial::write(unsigned int) <near match>
     inline size_t write(unsigned int n) { return write((uint8_t)n); }
                   ^
C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/HardwareSerial.h:127:19: note:   no known conversion for argument 1 from 'uint8_t [30] {aka unsigned char [30]}' to 'unsigned int'
C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/HardwareSerial.h:128:19: note: size_t HardwareSerial::write(int) <near match>
     inline size_t write(int n) { return write((uint8_t)n); }
                   ^
C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/HardwareSerial.h:128:19: note:   no known conversion for argument 1 from 'uint8_t [30] {aka unsigned char [30]}' to 'int'
In file included from C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Stream.h:26:0,
                 from C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/HardwareSerial.h:29,
                 from C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Arduino.h:224,
                 from C:\Program Files (x86)\Arduino\libraries\VirtualWire/VirtualWire.h:146,
                 from reciwedec.ino:1:
C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Print.h:49:12: note: size_t Print::write(const char*) <near match>
     size_t write(const char *str) {
            ^
C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Print.h:49:12: note:   no known conversion for argument 1 from 'uint8_t [30] {aka unsigned char [30]}' to 'const char*'
call of overloaded 'write(uint8_t [30])' is ambiguous

why?
plz help.
how to obtain data for use in
aes128_dec_single(key, buf);

Post the entire program, using code tags ("</>" button). The error messages are meaningless, except, of course, this line suggesting nonsensical code:

reciwedec:37: error: call of overloaded 'write(uint8_t [30])' is ambiguous
#include <VirtualWire.h>
#include <Wire.h> 
#include <LiquidCrystal_I2C.h>
#include <AESLib.h>

// Set the LCD address to 0x27 for a 16 chars and 2 line display
LiquidCrystal_I2C lcd(0x27, 16, 2);


void setup()
{
   delay(1000);
     
 lcd.begin();

 
 lcd.backlight();
   vw_setup(2000);  

   vw_rx_start();       // Start the receiver PLL running
}

void loop()
{
 Serial.begin(57600);
 uint8_t key[] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15};
   uint8_t buf[VW_MAX_MESSAGE_LEN];
   uint8_t buflen = VW_MAX_MESSAGE_LEN;

   if (vw_get_message(buf, &buflen)) // Non-blocking
   {
    
 int i;
  lcd.clear();
  

 
 Serial.print("Got: ");
 lcd.print("Got: ");
 
 for (i = 0; i < buflen; i++)
 {
    Serial.write(buf[i]);
    
       lcd.write(buf[i]);
       
 }
Serial.println();

    
   }
   delay(1000);
   lcd.clear();
   lcd.print("wait ");
}

This full program receiver.
I recive
Got: Y±§Ъm\ЊЇЎЪщCJК<‚ - data that must decipher

if I use aes128_dec_single(key, buf);
Serial.write(buf);
I get an error :frowning:

if I use aes128_dec_single(key, buf);
Serial.write(buf);
I get an error

The compiler is telling you what the problem is. The write() method of the HardwareSerial class (that Serial is an instance of) is overloaded. One version takes ONE byte. The other takes and array of bytes AND a number defining the size of the array.

Thanks a lot

aes128_dec_single(key, buf);
Serial.print("Got: ");
Serial.write(buf,buflen);

Got: testtesttesttest :wink: