new AES library

Hi,

I am working on simple encryption on my Arduino to be able to talk back and forth with web service, and stumbled upon this useful library. However, I have few questions regarding the CRC_decrypt and encrypt.

I got this example from somewhere in the thread and modify in a little bit.

#include <AES.h>

#define KEYLENGTH 32  // this means 32 bit encryption only following values are allowed 16, 128, 24, 192, 32, 256
AES aes;
char PassString[] = "This is hard to believe but true however";// this must be at least KEYLENGTH characters long
byte my_iv[N_BLOCK] = 
{
  1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,
} ;
byte key[KEYLENGTH];
void setup()
{
	Serial.begin(115200);

	Serial.println("Starting AES test");
	for (int i = 0; i < KEYLENGTH; i++)
	{
		key[i] = PassString[i];
	}

	if (aes.set_key(key, KEYLENGTH) != 0)
	{
		Serial.println(F("Failed to set key"));
	}

}

// The loop function is called in an endless loop
void loop()
{

	char Message[] = "A top secret message. 123456789012345678901234";
	byte plain[N_BLOCK];
	byte cipher[N_BLOCK];
	byte decrypted[N_BLOCK];

  byte iv [N_BLOCK] ;
  
	Serial.print(F("message : '"));
	Serial.print(Message);
	Serial.println(F("'"));
	Serial.print(F("plain binary: '"));
	for (int i = 0; i < N_BLOCK; i++)
	{
		plain[i] = Message[i];
		cipher[i] = 0;
		decrypted[i] = 0;
		Serial.print(plain[i]);
	}
	Serial.println(F("'"));

	Serial.print(F("plain char: '"));
	for (int i = 0; i < N_BLOCK; i++)
	{
		Serial.print(char(plain[i]));
	}
	Serial.println(F("'"));

for (byte i = 0 ; i < 16 ; i++)
      iv[i] = my_iv[i] ;
	if (aes.cbc_encrypt(plain, cipher,4,iv) == 0)
	{
		Serial.print(F("encrypted : '"));
		for (int i = 0; i < N_BLOCK; i++)
		{
			Serial.print(cipher[i]);
		}
		Serial.println(F("'"));
	} else
	{
		Serial.println(F("Failed to encrypt"));
	}

	if (aes.cbc_decrypt(cipher, decrypted,4,iv) == 0)
	{
		Serial.print(F("decrypted binary : '"));
		for (int i = 0; i < N_BLOCK; i++)
		{
			Serial.print(decrypted[i]);
		}
		Serial.println(F("'"));

		Serial.print(F("decrypted char : '"));
		for (int i = 0; i < N_BLOCK; i++)
		{
			Serial.print(char(decrypted[i]));
		}
		Serial.println(F("'"));
	} else
	{
		Serial.println(F("Failed to decrypt"));
	}

	delay(5000);
}

The result seemed to be stable, as in I get it decrypt and encrypt. How do I print those bytes in readable character? encrypted and decrypted plain text. if I cannot have this printed in ascii format, I cannot prove that I can decrypt the message in the web server.

Thanks.