Micro-channel notification refund, the refund callback data decryption

$ xmlResult = file_get_contents ( "php: // input"); // get the data micro-channel 
$ result = $ this-> xmlToArray ( $ xmlResult); // will turn into an array xml
// decrypting the encrypted data, the following method 
$ reqInfo = $ this-> refund_decrypt ( $ result [ 'req_info']);
 
/*
 * Refund notification decryption
 * @Author WangZhaoBo
 * @Param $ str micro-channel synchronized encryption string req_info
 * @Param $ key business key
 */
public function refund_decrypt($str) {
    $key = md5($this->appSecret);
    $str = base64_decode($str);
    $str = mcrypt_decrypt(MCRYPT_RIJNDAEL_128, $key, $str, MCRYPT_MODE_ECB);
    $block = mcrypt_get_block_size('rijndael_128', 'ecb');
    $pad = ord($str[($len = strlen($str)) - 1]);
    $len= Strlen ( $ p );
    $ pad = ord ( $ p [ $ len - 1 ]);
    return  substr ( $ p , 0, strlen ( $ p ) - $ pad );
}

 

Guess you like

Origin www.cnblogs.com/wangzhaobo/p/11040736.html