Skip to content

Instantly share code, notes, and snippets.

View CBox's full-sized avatar

Rafael Mor CBox

View GitHub Profile
<?
function aes128Encrypt($key, $data) {
if(16 !== strlen($key)) $key = hash('MD5', $key, true);
$padding = 16 - (strlen($data) % 16);
$data .= str_repeat(chr($padding), $padding);
return mcrypt_encrypt(MCRYPT_RIJNDAEL_128, $key, $data, MCRYPT_MODE_CBC, str_repeat("\0", 16));
}
function aes256Encrypt($key, $data) {