时间:2021-07-01 10:21:17 帮助过:27人阅读
加密:
/**
* 加密
* @param$originalData
* @return string|void
*/
/*function encrypt($originalData){
//if (openssl_private_encrypt($originalData, $encryptData, $this->rsaPrivateKey)) {
if (openssl_public_encrypt($originalData, $encryptData, $this->rsaPublicKey)) {
return base64_encode($encryptData);
} else {
return false;
}
}*/
function encrypt($originalData){
$crypto = '';
foreach (str_split($originalData, 117) as $chunk) {
openssl_public_encrypt($chunk, $encryptData, $this->rsaPublicKey);
$crypto .= $encryptData;
}
return base64_encode($crypto);
}
解密:
/**
* 私钥解密
* @param$encryptData*/ /*function decrypt($encryptData){
//if (openssl_public_decrypt(base64_decode($encryptData), $decryptData, $this->rsaPublicKey)) {
if (openssl_private_decrypt(base64_decode($encryptData), $decryptData, $this->rsaPrivateKey)) {
return$decryptData;
} else {
return false;
}
}*/
function decrypt($encryptData){
$crypto = '';
foreach (str_split(base64_decode($encryptData), 128) as $chunk) {
openssl_private_decrypt($chunk, $decryptData, $this->rsaPrivateKey);
$crypto .= $decryptData;
}
return$crypto;
}
Author:leedaning
本文地址:http://blog.csdn.net/leedaning/article/details/51780511
以上就介绍了 php使用openssl进行Rsa长数据加密117解密128,包括了方面的内容,希望对PHP教程有兴趣的朋友有所帮助。