谁能帮我把我提供的PHP代码翻译成JAVA代码,谢谢,是进行解密操作,十万火急。
PHP代码如下:
function decrypt($ciphertext, $secret)
{
$ciphertext = base64_decode($ciphertext); if (empty($ciphertext)) { return false;
}
$md5_v = md5($secret);
//Open the cipher
$td = mcrypt_module_open('rijndael-128', '', 'cbc', '');
//Create key and IV,不满 16 字符后面补\0
$key = substr($md5_v, 0, 16);
$iv = strrev(substr($md5_v, 0, 16));
//Intialize encryption mcrypt_generic_init($td, $key, $iv);
//Encrypt data
$plaintext = mdecrypt_generic($td, $ciphertext);
//Terminate encryption handler and close module
mcrypt_generic_deinit($td);
mcrypt_module_close($td); return trim($plaintext);
}
需要的sccert值:wZIejNGYIrQyQ14RMGKIjyxdt53WBVvz
密文(ciphertext):5mKh5ekXVNmztkSeLn1Jcu0f1RNAwsH9Q7xV1txk0FfSErydbSHmHES5bL1aD+bitE/bKN63DQ26+z7rsXx/RGV42qYa4c4MKpkSYiYKrEeRLrxwI/rxq7BqvbID3LbqAppqXWxtStKoSlPRbKo13/UWGNgVJENvGKYK8kjoVx4BE3YtsocRsloJ4y4wJfOi