AES on Arduino Uno - Need Help

Guys, I've asked this question on stackexchange. I'm not going to copy paste it since it's a bit long.
You can find it here: programming - AES Simplified for Arduino - Having hard time achieving desired result - Arduino Stack Exchange

Please note that we need help with this problem. If any developer is interested in assisting us we'd love to talk about this over the phone, e-mail or here.

Thanks in advance.

Not sure what the problem is. I ran the demo program using IDE 1.6.0 and an Uno and it worked fine. What are you seeing when you compile and run the program?

It compiles fine, however, I need to set the key as plain text instead of hex. How can I do this? Same goes for the message that needs encryption.

If you want the output displayed in a different form, just change the DUMP macro.

#include "aes256.h" //Include library files
#define DUMP(str, i, buf, sz) { Serial.println(str); \
    for(i=0; i<(sz); ++i) { if(buf[i]<0x10) Serial.print('0'); Serial.print(char(buf[i]), HEX); } \
    Serial.println(); } //Help function for printing the Output

aes256_context ctxt;

void setup() {
  int i;
  Serial.begin(9600);

  Serial.println("Initializing AES256... ");

  uint8_t key[] = { 
    0, 1, 2, 3, 4, 5, 6, 7,
    8, 9, 10,11, 12, 13, 14, 15,
    16, 17, 18, 19, 20, 21, 22, 23,
    24, 25, 26, 27, 28, 29, 30, 31
  };
  DUMP("Key: ", i, key, sizeof(key));
  aes256_init(&ctxt, key);

 uint8_t data[] = { 
   'a', 's', 'd', 'f',  'a', 's', 'd', 'f',
    'a', 's', 'd', 'f', 'a', 's', 'd', 'f'};
  DUMP("Unencrypted data: ", i, data, sizeof(data));

  aes256_encrypt_ecb(&ctxt, data);
  DUMP("Encrypted data: ", i, data, sizeof(data));

  aes256_decrypt_ecb(&ctxt, data);
  DUMP("Back decrypted data: ", i, data, sizeof(data));

  aes256_done(&ctxt);
}

void loop() {
}

How is this working? I'm getting:

Unencrypted data:
61736466617364666173646661736466

Instead of asdfasdfasdfasdf
...

If you want the output displayed in a different form, just change the DUMP macro.

Gees, did you read the entire post? Seems like you should do some of the work. Hint:
61736466617364666173646661736466 is also
61736466
61736466
61736466
61736466

I just removed 'HEX' from the macro and the output looks good. Sorry.
One other thing, I'm getting:

Encrypted data:
̲)nÆ•¬~€W. À

Can I convert this into base64 string that I can decrypt for example using this? http://aesencryption.net/

Thanks.

My guess is that you're reading past the end of the string, which means the data is not null terminated for printing.

Also, I'm still not sure you understand what I was saying:

61736466617364666173646661736466 is also
61736466
61736466
61736466
61736466

where
61 (hex) = 6 * 16 + 1 = 97 (decimal) = 'a' (ASCII)
73 (hex) = 7 * 16 + 3 = 115 (decimal) = 's' (ASCII)
64 (hex) = 6 * 16 + 4 = 100 (decimal) = 'd' (ASCII)
66 (hex) = 6 * 16 + 6 = 102 (decimal) = 'f' (ASCII)