Slow encryption AES256 as speed?

Good afternoon. The issue is: my program needs to store some user data in encrypted form. I found the implementation of the algorithm AES256, wrote a function to encrypt the file. All is good, but encryption is very slow.

void MyEncryptFile() {
 aes256_context ctx;
 uint8_t BUFFER[16];
 uint8_t PASSWORD[32] = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f };
 FILE *ff1 = fopen("E:\\picture.jpg", "rb");
 FILE *ff2 = fopen("E:\\picture.jpg.encrypt", "wb");
 aes256_init(&ctx, PASSWORD);
 while (!feof(ff1))
 fread(BUFFER, sizeof(uint8_t), 16, ff1);
 aes256_encrypt_ecb(&ctx, BUFFER);
 fwrite(BUFFER, sizeof(uint8_t), 16, ff2);

File size 1.23 MB encrypts about a minute. I crookedly implemented,or the implementation of the AES available? Or this is normal and as it should be? But then like TrueCrypt encrypts "on the fly"?

The AES implementation:
Please help me
June 5th 19 at 21:49
2 answers
June 5th 19 at 21:51
use any openssl with hardware accelerated aes.
June 5th 19 at 21:53
Well, if the result of the encryption is decrypted, encrypted and coincides with other programs data, all right.
The problem is that often implemented in the forehead, the algorithms perform a lot of repetitive work that can be optimized. At least in processors 8-byte registers, and most of the operations in the algorithm is a single - byte.
To optimize you can and should use a Profiler that shows bottlenecks, you can try to optimize.
When you compile you need to specify the parameters for maximum acceleration.

For implementation you can use special processor instructions AES-NI, which is used in truecrypt.

Find more questions by tags AESC++