Created
April 18, 2012 01:47
-
-
Save run26kimo/2410484 to your computer and use it in GitHub Desktop.
php_des_ecb_encrypt
This file contains 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
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