Skip to content

Instantly share code, notes, and snippets.

@bricef
Created April 21, 2012 18:17
Show Gist options
  • Save bricef/2438927 to your computer and use it in GitHub Desktop.
Save bricef/2438927 to your computer and use it in GitHub Desktop.
AES Decryption in C
int decrypt(
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);
if( buffer_len % blocksize != 0 ){return 1;}
mcrypt_generic_init(td, key, key_len, IV);
mdecrypt_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