private function rsa_enc_des($aesKey,$cert_key,$flag){
if($flag==1){
$cert_public_path=$cert_key;
$public_key = openssl_pkey_get_public(file_get_contents($cert_public_path));
openssl_public_encrypt($aesKey,$encAesKey,$public_key);
framework_static_function::write_log('返回参数加密后【aesKey】:'.$encAesKey,'caimaoInfo');
$res=base64_encode($encAesKey);
}elseif($flag==2){
$cert_private_path=$cert_key;
$private_key = openssl_pkey_get_private(file_get_contents($cert_private_path));
openssl_private_decrypt(base64_decode($aesKey),$merchantAESKey,$private_key);
framework_static_function::write_log('入参解密后明文【16位随机数】:'.$merchantAESKey,'caimaoInfo');
$res=$merchantAESKey;
}
return $res;
}
public function rsa_enc_des($aesKey,$flag){
if($flag==1){
$encrypted = "";
$cert_public_path=$this->hna_key;
$public_key = openssl_pkey_get_public(file_get_contents($cert_public_path));
foreach (str_split($aesKey, 117) as $chunk) {
openssl_public_encrypt($chunk,$encryptData,$public_key);
$encrypted .= $encryptData;
}
$res=base64_encode($encrypted);
}elseif($flag==2){
$decrypted = '';
$cert_private_path=$this->mer_key;
$private_key = openssl_pkey_get_private(file_get_contents($cert_private_path));
foreach (str_split(base64_decode($aesKey), 128) as $chunk) {
openssl_private_decrypt($chunk, $decryptData, $private_key);
$decrypted .= $decryptData;
}
$res=$decryptData;
}
return $res;
}