Skip to content

Instantly share code, notes, and snippets.

Pavel Gerashchenko pvels

Block or report user

Report or block pvels

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
pvels / gist:762d8fbd020ad60a11b7
Last active Oct 28, 2015 — forked from RiANOl/gist:1077723
AES128 / AES256 CBC with PKCS7Padding in PHP
View gist:762d8fbd020ad60a11b7
function aes128_cbc_encrypt($key, $data, $iv) {
if(16 !== strlen($key)|| ctype_xdigit($key)) $key = hash('MD5', $key, true);
if(16 !== strlen($iv) || ctype_xdigit($iv)) $iv = hash('MD5', $iv, true);
$padding = 16 - (strlen($data) % 16);
$data .= str_repeat(chr($padding), $padding);
return mcrypt_encrypt(MCRYPT_RIJNDAEL_128, $key, $data, MCRYPT_MODE_CBC, $iv);
You can’t perform that action at this time.