/**
* RSA加密
* @throws \Exception
*/
public function fingerprintUnlock($eb64_cry)
{
header("Content-type: text/html; charset=utf-8");
define('RSA_PUBLIC', '-----BEGIN PUBLIC KEY-----
MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDAQ6/3o5lP831fnwmfYr/AAc6Q
Vvosbre**********************************************HawlTut6EVz
kSlY1jQVw+5*********************TSsSdfeY5OWwGg8V+oHlUxPoobTi5bKd
I941/FKarFh/tlg/TQIDAQAB
-----END PUBLIC KEY-----');
define('RSA_PRIVATE','-----BEGIN PRIVATE KEY-----
MIICdwIBADANBgkqhkiG9w0BAQEFAASCAmEwggJdAgEAAoGBAMBDr/ejmU/zfV+f
CZ9iv8ABzpBW+ixut7FX4f7SIk+R/HDRYmNgCbgHHciGrofJ46kVcQYStoyKJJmE
drCVO6************************************************AaDxX6geVT
E+ihtOLlsp0j3jX8UpqsWH+2WD9NAgMBAAECgYBYcosQDEXqPuRtSdd+aEo4BVzG
kAy0xhZhUkGYHYlFO657JAf0GWk/LJ7p8fN2akz+Kuv81D0AeEiQCx0i7PQvp6na
WBcRib7qoKyK3cUJmtMt6ovpmufLKd9+fgvQwEYcucoMUU+tvvhlERBEBJ54YsTU
3cVtrY+fRQ********************************CWwp+RHPF83fjVTu+9eAfK
N7YkcOAg459+ud+UxvsgyZh2JIFHtyOusNDYiQaX7PsCQQDbuce4BVJbhLAOUW+T
KNLn/CEgd4UCVg9wDjY6NnJGYV75zCPmEDQMWVz56KraEsDA/GIPfAiBSgcLWhK6
ekJXAkAxIHjF81jgqDj4UEUvxuRqUoYKgsPLPmxcF0QBlhcN9k5zlthefzgMkblo
DHP7PXyZAEgPRlAm9jf3BZY/qPAjAkEAxBGuz14oVLQ9qjkvGCE4unw5T1B351LG
ada0uxN0u6sN5lgsvJI+77oahoMBWqGbUVqlYm3q5Pwa9x1EUxTf9wJBAM8WJEn+
6oa0KipqEiezWX/zUy8KhAR+jv02YVOx0KE0eWDlie0yyV5h8PQ1WBuVvEutHw6q
SvZ1NRs+uqnJ3b4=
-----END PRIVATE KEY-----');
// //公钥加密
// $public_key = openssl_pkey_get_public(RSA_PUBLIC);
// if(!$public_key){
// die('公钥不可用');
// }
////第一个参数是待加密的数据只能是string,第二个参数是加密后的数据,第三个参数是openssl_pkey_get_public返回的资源类型,第四个参数是填充方式
// $return_en = openssl_public_encrypt("好好学习,太逆天上", $crypted, $public_key);
// if(!$return_en){
// return('加密失败,请检查RSA秘钥');
// }
// $eb64_cry = base64_encode($crypted);
// echo "公钥加密数据:".$eb64_cry;
// echo "<hr>";
//私钥解密
$private_key = openssl_pkey_get_private(RSA_PRIVATE);
if(!$private_key){
// die('私钥不可用');
return false;
}
$return_de = openssl_private_decrypt(base64_decode($eb64_cry), $decrypted, $private_key);
if(!$return_de){
// return('解密失败,请检查RSA秘钥');
return false;
}
return $decrypted;
// echo "私钥解密数据:".$decrypted;
// echo "<hr>";
//
//
// echo "<hr/>";
//
//
// //私钥加密
// $private_key = openssl_pkey_get_private(RSA_PRIVATE);
// if(!$private_key){
// die('私钥不可用');
// }
// $return_en = openssl_private_encrypt("hello world222222", $crypted, $private_key);
// if(!$return_en){
// return('加密失败,请检查RSA秘钥');
// }
// $eb64_cry = base64_encode($crypted);
// echo "私钥加密数据".$eb64_cry;
// echo "<hr>";
//
////公钥解密
// $public_key = openssl_pkey_get_public(RSA_PUBLIC);
// if(!$public_key){
// die('公钥不可用');
// }
// $return_de = openssl_public_decrypt(base64_decode($eb64_cry), $decrypted, $public_key);
// if(!$return_de){
// return('解密失败,请检查RSA秘钥');
// }
// echo "公钥解密数据:".$decrypted;
// echo "<hr>";
}