Skip to content

Instantly share code, notes, and snippets.

@bricef
Created April 21, 2012 16:06
Show Gist options
  • Select an option

  • Save bricef/2438023 to your computer and use it in GitHub Desktop.

Select an option

Save bricef/2438023 to your computer and use it in GitHub Desktop.
Encrypt with AES using C
int encrypt(
void* buffer,
int buffer_len,
char* IV,
char* key,
int key_len
){
MCRYPT td = mcrypt_module_open("rijndael-128", NULL, "cbc", NULL);
int blocksize = mcrypt_enc_get_block_size(td);
mcrypt_generic_init(td, key, key_len, IV);
mcrypt_generic(td, buffer, buffer_len);
mcrypt_generic_deinit (td);
mcrypt_module_close(td);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment