php加密解密
<?php function encrypt($input, $secureKey = '') { return base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_256, $secureKey, $input, MCRYPT_MODE_ECB, mcrypt_create_iv(32))); } function decrypt($input, $secureKey = '') { return trim(mcrypt_decrypt(MCRYPT_RIJNDAEL_256, $secureKey, base64_decode($input), MCRYPT_MODE_ECB, mcrypt_create_iv(32))); } $key = 'jEP0rqTnYZjC4XrqVGqPWqK91zBThVgRyXUOXZPFZ2ZP905D2c3Qqtolfbk0cAzY'; $key = hash('sha256', $key, true); $string = '小陈是一名应届毕业生。'; $encode_string = encrypt($string, $key); echo 'ENCODE: ' . $encode_string . '<br />'; echo 'DECODE: ' . decrypt($encode_string, $key) . '<br />';