hey, if i want to encrypt some text using one of the various methods, and the text is larger than 1024 bytes... how do i get the next 1024 bytes?
also, i discovered the EncryptFile() function, but what exactly does it do? does it just like "lock" files so that the current user has permissions for them and if another user on the system tries to access the file, they won't be able to?
also, i'm getting this error
undefined reference to `AES256_BytesMode@28'
for this code:
Code:
unsigned char key[32];
unsigned char plain[1024];
unsigned char cipher[1024];
long keybits;
unsigned char iv[16];
char *modes[] = { "ECB", "CBC" }, *buf, *length, *res;
int i, j, n, im, len;
long result;
HWND hwndEdit = GetDlgItem(hwnd,IDC_CHILD_EDIT);
srand((unsigned)time(NULL));
for (i = 0; i < 10; i++)
{
/* Set key size */
keybits = 256;
/* Create a random key */
for (j = 0; j < keybits / 8; j++)
key[j] = rand() & 0xFF;
/* and a random IV */
for (j = 0; j < sizeof(iv); j++)
iv[j] = rand() & 0xFF;
/* Select a mode index: 0 or 1 */
im = rand() & 0x01;
/* Create some 'random' plaintext up to 1024 bytes long */
/* in a multiple of block size */
n = ((rand() % 16) + 1) * 16;
len = GetWindowTextLength(hwndEdit);
itoa(len, length, 5);
MessageBox(hwnd, length, "Length of text:", MB_OK | MB_ICONINFORMATION);
if (len <= 0) { MessageBox(hwnd, "There is no text to encrypt.", "Error.", MB_OK | MB_ICONERROR); return FALSE; }
buf = (char*)malloc(len + 1);
GetDlgItemText(hwnd, IDC_CHILD_EDIT, buf, len);
for (j = 0; j < n; j++)
plain[j] = buf[j];
/* Encrypt it into ciphertext */
result = AES256_BytesMode(cipher, plain, n, key, ENCRYPT, modes[im], iv);
see anything wrong?
i can post more complete code if need be.
thanks