#include #include #include int main() { unsigned char userKey[32]; AES_KEY key; unsigned char text[16]; arc4random_buf(userKey, sizeof(userKey)); printf("key: %02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x" "%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x\n", userKey[0], userKey[1], userKey[2], userKey[3], userKey[4], userKey[5], userKey[6], userKey[7], userKey[8], userKey[9], userKey[10], userKey[11], userKey[12], userKey[13], userKey[14], userKey[15], userKey[16], userKey[17], userKey[18], userKey[19], userKey[20], userKey[21], userKey[22], userKey[23], userKey[24], userKey[25], userKey[26], userKey[27], userKey[28], userKey[29], userKey[30], userKey[31]); AES_set_encrypt_key(userKey, 256, &key); arc4random_buf(text, sizeof(text)); printf("plaintext: %02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x\n", text[0], text[1], text[2], text[3], text[4], text[5], text[6], text[7], text[8], text[9], text[10], text[11], text[12], text[13], text[14], text[15]); AES_encrypt(text, text, &key); printf("ciphertext: %02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x\n", text[0], text[1], text[2], text[3], text[4], text[5], text[6], text[7], text[8], text[9], text[10], text[11], text[12], text[13], text[14], text[15]); arc4random_buf(text, sizeof(text)); printf("plaintext: %02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x\n", text[0], text[1], text[2], text[3], text[4], text[5], text[6], text[7], text[8], text[9], text[10], text[11], text[12], text[13], text[14], text[15]); AES_encrypt(text, text, &key); printf("ciphertext: %02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x\n", text[0], text[1], text[2], text[3], text[4], text[5], text[6], text[7], text[8], text[9], text[10], text[11], text[12], text[13], text[14], text[15]); return 0; }