Created
April 21, 2012 16:06
-
-
Save bricef/2438023 to your computer and use it in GitHub Desktop.
Encrypt with AES using C
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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