JAVA DES encryption class, how to use PHP to achieve encryption, decryption

1, JAVA DES encryption class, how to use PHP to achieve encryption, decryption.
(1) encryption
if the key is 123mursharpAbcd, the plaintext is hello world, output 3d518daea941120d72fe3488f5d27a64
under this code, it will appear before data decryption is 87897DDA5754EAAE69E7F063E8B0962A, the plaintext is {"retcode": "2"}
code is as follows

/**
 * DES
 * @param string  $data   
 * @param string  $key    (64bit-->8byte; 128bit-->16byte; 256bit-->32byte)
 * @param string  $iv     , : 0123456789123456
 * @return string   
 */
function des_encrypt($data, $key, $iv="", $padding="\0") {
    $blocksize = 16;
    $pad = $blocksize - (strlen($data) % $blocksize);       //
    $data = $data . str_repeat($padding, $pad);     //\0
    return bin2hex(mcrypt_encrypt(MCRYPT_DES, $key, $data, MCRYPT_MODE_ECB, $iv));
}

/**
 * DES
 * @param string  $data   
 * @param string  $key    (64bit-->8byte; 128bit-->16byte; 256bit-->32byte)
 * @param string  $iv     , : 0123456789123456
 * @return string   
 */
function des_decrypt($data, $key, $iv="", $padding="\0") {
    //, 
    return rtrim(mcrypt_decrypt(MCRYPT_DES, $key, hex2bin($data), MCRYPT_MODE_ECB, $iv), $padding);
}
echo des_encrypt("hello world", "123-sharpAbcd")."</br>";
Mar.04,2021
Menu