function rsa_decrypt($message, $private_key, $modulus, $keylength) { $number = binary_to_number($message); $decrypted = pow_mod($number, $private_key, $modulus); $result = number_to_binary($decrypted, $keylength / 8); return remove_PKCS1_padding($result, $keylength / 8); }
function remove_PKCS1_padding_md5($data, $blocksize) { $digestinfo = remove_PKCS1_padding($data, $blocksize); $digestinfo_length = strlen($digestinfo); //md5 digestinfo length not less than 16 //assert($digestinfo_length >= 16); return substr($digestinfo, $digestinfo_length - 16); }