Skip to content

Instantly share code, notes, and snippets.

@run26kimo
Created April 18, 2012 01:47
Show Gist options
  • Save run26kimo/2410484 to your computer and use it in GitHub Desktop.
Save run26kimo/2410484 to your computer and use it in GitHub Desktop.
php_des_ecb_encrypt
function encrypt($str, $key)
{
$block = mcrypt_get_block_size('des', 'ecb');
$pad = $block - (strlen($str) % $block);
$str .= str_repeat(chr($pad), $pad);
return base64_encode(mcrypt_encrypt(MCRYPT_DES, $key, $str, MCRYPT_MODE_ECB));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment