Combination signature $a=time (); $b =substr ($a, 1);//Generate random order number $orderid= $b. Mt_rand (10000,99999);//co-Identity ID, 16-bit pure number starting with 2088 $mygoods [' partner ']= "2088011744308664";//Merchant account $mygoods[' seller ']= "[email protected]";//Order number $mygoods[' Out_ Trade_no ']= $orderid;//Theme $mygoods[' subject ']= $goods _name;//Product description Information $mygoods[' body ']= $goods _infro;//commodity price $mygoods[' Total_fee ']= $score;//server-side asynchronous response Address $mygoods[' Notify_url ']= "http://211.149.220.47/php/notify_url.php";//Sort $ Mygoods = argsort ($mygoods);//Stitching $mystr = createlinkstring ($mygoods);//Signature $sign = Rsasign ($MYSTR);//UrlEncode transcoding $sign = urlencode ($sign) for signatures,//Generate final signature information $orderinfor = $mystr. " &sign= ". $sign." &sign_type=rsa "; /** * all elements of the array, using" & "characters in the" parameter = parameter value "pattern to string * @param $para need to splice the array * return stitching complete after the string */function createlinkstring ($para) { $arg = ""; while (list ($key, $val) = each ($para)) { $arg. = $key. " = ". $val." & "; } //remove the last & character $arg = substr ($arg, 0,count ($arg)-2); //If an escape character is present, remove the escape if (GET_MAGIC_QUOTES_GPC ()) {$arg = stripslashes ($arg);} return $arg;} /** * array sort * @param $para sort before sorting * return sorted array */function argsort ($para) { ksort ($para); reset ($para); return $para;} /** * rsa Signature * @param $data data to be signed * @param $private _key_path Merchant private key file path * return signature result */function rsasign ($data, $private _key_path) { $priKey = file_Get_contents ($private _key_path); $res = openssl_get_privatekey ($priKey); openssl_sign ($data, $sign, $res); openssl_free_key ($ RES); //base64 encoding $sign = base64_encode ($sign); return $sign;}
This article is from the "Faith Connaught Group Technology Center" blog, please be sure to keep this source http://sinoteam.blog.51cto.com/9115640/1441247
PHP to do RSA signature generation order