我有一个遗留数据库,其内容是使用 DES 通过 mcrypt 加密的(是的,我知道,那是很久以前的事了)加密方法如下:
/**
* General encryption routine for generating a reversible ciphertext
* @param String $string the plain text to encrypt
* @param String $key the encryption key to use
* @return String the cypher text result
*/
function encrypt($string, $key)
{
srand((double) microtime() * 1000000);
/* Open module, and create IV */
$td = mcrypt_module_open('des', '', 'cfb', '');
$ksub = substr(md5($key), 0, mcrypt_enc_get_key_size($td));
$iv_size = mcrypt_enc_get_iv_size($td);
$iv = mcrypt_create_iv($iv_size, MCRYPT_RAND);
/* Initialize encryption handle */
if …Run Code Online (Sandbox Code Playgroud)