Variable message size on AES encryption/decryption

This code here: https://github.com/spaniakos/AES/blob/master/examples_Rpi/aes.cpp encrypts and decrypts messages of certain size. I need to make it able to encrypt/decrypt variable message sizes. For this reason I changed this:

byte plain[] = "TESTTESTTESTTESTTESTTESTTESTTESTTESTTESTTESTTESTTESTTESTTEST";

to this:

byte *plain;

But it does not work! Any idea?

Just to inform you that I input the messages from the Serial (Keyboard).

"It does not work" contains no information.
What comes out of the try?

1 Like

Nothing comes out. However If I put the follwoing command:

byte plain[] = "Hello World!";

on the output I get the sentence: Hello World! plus carbage (irrelevant characters)...

That's a different kind of access. End the string with an ascii null character to end the string to cut the garbage!

1 Like

@Railroader Railroader: You are Amazing! The garbage disappeared! How do I make the text I send to the Serial of variable length? I am reading malloc documentation, but I am not sure it is the right approach...

That's charbage.

a7

1 Like

Send a string, ending with the null character to serial.

1 Like

This link you pointed to has an example:

" https://github.com/spaniakos/AES/blob/master/examples/test_vectors/test_vectors.pde

Have you already tested it?

1 Like

I have a lot of errors! I cannot run it...

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.