跳转到帖子
登录关注  
墨香年少

Linux安装openssl3.2.0

已推荐帖子

 1007  openssl version
 1008  cls
 1009  wget https://www.openssl.org/source/openssl-3.2.0.tar.gz
 1010  tar -zxvf openssl-3.2.0.tar.gz 
 1011  cd openssl-3.2.0
 1012  yum install -y perl-CPAN
 1013  yum install perl-IPC-Cmd
 1014  ./config  --prefix=/usr/local/openssl
 1015  make -j 32
 1016  make install
 1017  vi /etc/ld.so.conf
 1018  ldconfig
 1019  mv /usr/bin/openssl /usr/bin/openssl.bak
 1020  mv /usr/include/openssl /usr/include/openssl.bak 
 1021  ln -s /usr/local/openssl/bin/openssl /usr/bin/openssl
 1022  ln -s /usr/local/openssl/include/openssl/  /usr/include/openssl
 1023  openssl version
 1024  cls
 1025  history

输出:

[root@debugserver openssl-3.2.0]# openssl version
OpenSSL 3.2.0 23 Nov 2023 (Library: OpenSSL 3.2.0 23 Nov 2023)


目之所及,皆是回忆,心之所想,皆是过往

分享这篇帖子


链接帖子
分享到其他站点

生成密钥
openssl genrsa -aes128 -out private.pem -passout pass:123456 2048

 

生成公钥
openssl rsa -pubout -in private.pem -out public.pem


目之所及,皆是回忆,心之所想,皆是过往

分享这篇帖子


链接帖子
分享到其他站点

公钥加密 私钥解密

<?php
$string = "hello world";
$public_key = file_get_contents("public.pem");

openssl_public_encrypt($string,$encrypt_string, $public_key);
$public_encrypted_string = base64_encode($encrypt_string);
echo "公钥加密后:".$public_encrypted_string;
echo "<hr />";

$private_key = file_get_contents("private.pem");
$private_key = openssl_pkey_get_private($private_key,'123456');

openssl_private_decrypt(base64_decode($public_encrypted_string),$private_decrypted_string,$private_key);
echo "私钥解密后:".$private_decrypted_string;
?>

输出:

公钥加密后:K06s8itA/N2yGzb0p59k2488sQGBPqbqX6fKEoIIabkB5lIMSJDoseT8PBlviA+Zo3jf00vd1qdZ9pwUwqLmkeVuhclYnAC9kaF2nuu8CmLDOAlvD8spsEQt5fQohupFhOeIUior2fCFhNj9bqONXESow68px7UNddUN+hbx1YsPt6jhytQkbOFEmvJHmJv33hJQH2XjPfNITuU3WMj0ESGWmC3wJUaVWl+wWofZmw1rwUNZD4p8SKWc0KgB2AVN4L/HXmhK/5QUuUmvO2lAeCh/s8egiiGzsbDJm+3YTSSSzQz3PhlsHTiUGmcQERr+jcYoS+ZoTkRGzdP2rDeLuA==

私钥解密后:hello world


目之所及,皆是回忆,心之所想,皆是过往

分享这篇帖子


链接帖子
分享到其他站点

私钥加密 公钥解密

<?php
//私钥加密 公钥解密
$private_key = file_get_contents("private.pem");
$private_key = openssl_pkey_get_private($private_key,'123456');

$string = "I love you but you married someone else!";
openssl_private_encrypt($string,$private_encrypt_string,$private_key);
$private_encrypt_string = base64_encode($private_encrypt_string);
echo '私钥加密:'.$private_encrypt_string;
echo "<hr />";

//公钥解密
$public_key = file_get_contents("public.pem");
openssl_public_decrypt(base64_decode($private_encrypt_string),$public_decrypted_string,$public_key);
echo '公钥解密:'.$public_decrypted_string;

输出:

私钥加密:

UDtk4A0ij48dbDJcoNqV45osVazSYTYOoH1ieAPgkhb6tsaszeF3hNtaDrxkDRuKHJiUEfG4ukR6MhyDsiTrzYQf/PENXPxm+4fMvZnqiDCPvdDjD1wH3QPw1/mVVphFwO33fauIN3vVIaeDroRJVgb9Fq3os/tYy1/auObUzsUWv8n1k4vsFsknbL/69f8sydurcIZIBm05YJERpd8fzvbCAEXAx7df44s+vFLZh+nIRq/HGXEUfx7t9s/J6hW44bJOD11YtwSk2Zgw9/G48qAvGRH2ZReiPXpwZ4AtXoJdNTrUBSSLDfeimk+PXNYIn7FNNwkTjZF94iAtZH/01Q==

 

公钥解密:I love you but you married someone else!


目之所及,皆是回忆,心之所想,皆是过往

分享这篇帖子


链接帖子
分享到其他站点

public.pem内容如下:

-----BEGIN PUBLIC KEY-----
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAnk4CmS/EJxzEDZCwftdg
QFWdk6R2WQaDLujY2b7q3eLR+b+8FJgwwFyLa96sJsmtp27lWMJKpX5kIjwG1091
aw6PNce7VZSa5RHWoTprcXWiyCQBR6CC+F3KsdsPDtIsWPSfXO9FA5UJC6G1Pofb
xWSPBbayoRIlxcsGV+Gm6eAvZghZ+s79u0CGc9GNKG0SPFJuuxx4ixSWchQHd9Ow
2vzQuN7yJG4vo4sAhdUUTTBvTa8jhebDO2A8ViwEmVw5qkn3qXZfNCJohkf88gSb
gYEmSsjHBBorL/7VSJ28nzejqtmFr9zQYExkHmCR/E0rGiW/CX0eOi4pEF7WDivv
YwIDAQAB
-----END PUBLIC KEY-----

 


目之所及,皆是回忆,心之所想,皆是过往

分享这篇帖子


链接帖子
分享到其他站点

private.pem内容如下:

-----BEGIN ENCRYPTED PRIVATE KEY-----
MIIFNTBfBgkqhkiG9w0BBQ0wUjAxBgkqhkiG9w0BBQwwJAQQOK8dtKgkLYhVrCvT
H1sApwICCAAwDAYIKoZIhvcNAgkFADAdBglghkgBZQMEAQIEEIHzRTJuFe9RCFJh
7VyNprgEggTQiHManjAoSGJrD2KXnom5lirDcdNpUBwzWB0QYgTGrHSm9Frzw0za
ugfvHoHZ/joH9rInn5rrpL5Z7SHrcJp9wOK4QZd7rB+a4DeY5Rvwe6AyikEXsug5
5SZqK/7vmkbzxmgxt6LlaX99vyDaxqHb79HF7IGc7jz9vIoILV5jQeTNfVUn/kYS
RX1l59KwVOkNkJR2nyphYrT9Adu5xmOigKYIEU7R6TNSELWZccMYTvRkc3tUggNo
XDxEkB+/+Fzo+A+oEPj9aNesZbZLCZv2EBP7tlVM/28ScJulRGgZ5zK/roMMzgb2
bMjQ432WseKcyuhrwo0SCmJTxKEzISLqITokVjqPL9gZ1/376ZmcoXWFRbKaj+wf
Le10OtHq1OvQMjQE+kmlqDtjVYbm6/+1GXIkbl5sitU/alc3dwiR1DhINOehWTAF
qbfNqBp2hi5vn/n3c8ZCZgm4vWnW6WjYOJtEJSzDJKARubgIEKyuht9zFj2w8Ans
EnL5/qiJ1HirbWXayRHHGMR0y9UpRCPuUL08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KXXWzDFaYMSHBY6THcSLwAdzqBeZJHoFh/qqAAPbgKA4+ShNOsmQ=
-----END ENCRYPTED PRIVATE KEY-----

 


目之所及,皆是回忆,心之所想,皆是过往

分享这篇帖子


链接帖子
分享到其他站点

创建帐户或登录来提出意见

你需要成为会员才能提出意见

创建帐户

注册成为会员。只要几个简单步骤!

注册帐户

登录

已有帐户? 请登录。

现在登录
登录关注  

×
×
  • 创建新的...

重要信息

注册必须使用2-8个中文汉字作为账号