php加密方式:SHA256方法

**私钥加密:**ksort( $params );//数组排序$signData 		= implode( '', $params );$pi_key 			= openssl_pkey_get_private($rsaPriKey);//私钥$signature		='';openssl_sign( $signData, $signature, $pi_key, OPENSSL_ALGO_SHA256 );openssl_free_key($pi_key);$params['sign'] 	= base64_encode($signature);**验证:**$sign = base64_decode($sign);//验证公钥是否可用$pu = openssl_get_publickey($this->merchant_public_key);//公钥验证$isSuccess = (bool)openssl_verify ($returnArray,$sign,$pu,OPENSSL_ALGO_SHA256);

Published by

风君子

独自遨游何稽首 揭天掀地慰生平

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注