您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

银联接口的mcrypt_cbc问题

2025/9/12 18:47:58发布37次查看
用了php5.5 银联接口netpayclient.php 的mcrypt_cbc不能用了,该怎么替换?
// this file is protected by copyright law & provided under license. copyright(c) 2005-2009 www.chinapay.com, all rights reserved.// this file is protected by copyright law & provided under license. copyright(c) 2005-2009 www.chinapay.com, all rights reserved.define(des_key, scubepgw);define(hash_pad, 0001ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff003021300906052b0e03021a05000414);bcscale(0);$private_key = array(); /*function hex2bin($hexdata) { $bindata = ''; if (strlen($hexdata) % 2 == 1) { $hexdata = '0' . $hexdata; } for ($i = 0; $i 0) { $pad = str_repeat($chr, $padlen); if (strtoupper($d) == 'l') { $ret = $pad . $ret; } else { $ret = $ret . $pad; } } return $ret;} function bin2int($bindata) { $hexdata = bin2hex($bindata); return bchexdec($hexdata);} function bchexdec($hexdata) { $ret = '0'; $len = strlen($hexdata); for ($i = 0; $i = 0) { $result = bcsub($a, $b); } else { $result = bcsub($b, $a); $result = bcsub($p, $result); } $result = bcmod($result, $p); $result = bcmul($result, $u); $result = bcmod($result, $p); $result = bcmul($result, $q); $result = bcadd($result, $b); $ret = bcdechex($result); $ret = strtoupper(padstr($ret)); return (strlen($ret) == 256) ? $ret : false;} function rsa_decrypt($input) { global $private_key; $check = bchexdec($input); $modulus = bin2int($private_key[modulus]); $exponent = bchexdec(010001); $result = bcpowmod($check, $exponent, $modulus); $rb = bcdechex($result); return strtoupper(padstr($rb));} function buildkey($key) { global $private_key; if (count($private_key) > 0) { foreach ($private_key as $name => $value) { unset($private_key[$name]); } } $ret = false; $key_file = parse_ini_file($key); if (!$key_file) { return $ret; } $hex = ; if (array_key_exists(merid, $key_file)) { $ret = $key_file[merid]; $private_key[merid] = $ret; $hex = substr($key_file[prikeys], 80); } else if (array_key_exists(pgid, $key_file)) { $ret = $key_file[pgid]; $private_key[pgid] = $ret; $hex = substr($key_file[pubkeys], 48); } else { return $ret; } $bin = hex2bin($hex); $private_key[modulus] = substr($bin, 0, 128); $cipher = mcrypt_des; $iv = str_repeat(\x00, 8); $prime1 = substr($bin, 384, 64); $enc = mcrypt_cbc($cipher, des_key, $prime1, mcrypt_decrypt, $iv); $private_key[prime1] = $enc; $prime2 = substr($bin, 448, 64); $enc = mcrypt_cbc($cipher, des_key, $prime2, mcrypt_decrypt, $iv); $private_key[prime2] = $enc; $prime_exponent1 = substr($bin, 512, 64); $enc = mcrypt_cbc($cipher, des_key, $prime_exponent1, mcrypt_decrypt, $iv); $private_key[prime_exponent1] = $enc; $prime_exponent2 = substr($bin, 576, 64); $enc = mcrypt_cbc($cipher, des_key, $prime_exponent2, mcrypt_decrypt, $iv); $private_key[prime_exponent2] = $enc; $coefficient = substr($bin, 640, 64); $enc = mcrypt_cbc($cipher, des_key, $coefficient, mcrypt_decrypt, $iv); $private_key[coefficient] = $enc; return $ret;} function sign($msg) { global $private_key; if (!array_key_exists(merid, $private_key)) { return false; } $hb = sha1_128($msg); return rsa_encrypt($private_key, $hb);} function signorder($merid, $ordno, $amount, $curyid, $transdate, $transtype) { if (strlen($merid) != 15) return false; if (strlen($ordno) != 16) return false; if (strlen($amount) != 12) return false; if (strlen($curyid) != 3) return false; if (strlen($transdate) != 8) return false; if (strlen($transtype) != 4) return false; $plain = $merid . $ordno . $amount . $curyid . $transdate . $transtype; return sign($plain);} function verify($plain, $check) { global $private_key; if (!array_key_exists(pgid, $private_key)) { return false; } if (strlen($check) != 256) { return false; } $hb = sha1_128($plain); $hbhex = strtoupper(bin2hex($hb)); $rbhex = rsa_decrypt($check); return $hbhex == $rbhex ? true : false;} function verifytransresponse($merid, $ordno, $amount, $curyid, $transdate, $transtype, $ordstatus, $check) { if (strlen($merid) != 15) return false; if (strlen($ordno) != 16) return false; if (strlen($amount) != 12) return false; if (strlen($curyid) != 3) return false; if (strlen($transdate) != 8) return false; if (strlen($transtype) != 4) return false; if (strlen($ordstatus) != 4) return false; if (strlen($check) != 256) return false; $plain = $merid . $ordno . $amount . $curyid . $transdate . $transtype . $ordstatus; return verify($plain, $check);}
回复讨论(解决方案) 自php 5.5.0起,此函数已经被废弃。强烈建议不要使用此函数 。
http://www.php.net/manual/zh/function.mcrypt-cbc.php
我知道弃用了,但是银联的接口用的就是这个,我想知道怎么改,谢谢
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product