{"id":244,"date":"2022-11-09T23:01:56","date_gmt":"2022-11-09T15:01:56","guid":{"rendered":"https:\/\/blog.messyghost.net\/?p=244"},"modified":"2022-12-09T13:12:11","modified_gmt":"2022-12-09T05:12:11","slug":"%e5%9c%a8%e4%bd%bf%e7%94%a8%e4%b8%8d%e4%bf%a1%e4%bb%bb%e7%9a%84%e9%80%9a%e4%bf%a1%e6%89%8b%e6%ae%b5%e6%97%b6%e8%bf%9b%e8%a1%8c%e5%ae%89%e5%85%a8%e7%9a%84%e4%bf%a1%e6%81%af%e4%ba%a4%e6%8d%a2","status":"publish","type":"post","link":"https:\/\/blog.messyghost.net\/?p=244","title":{"rendered":"\u5728\u4f7f\u7528\u4e0d\u4fe1\u4efb\u7684\u901a\u4fe1\u624b\u6bb5\u65f6\u8fdb\u884c\u5b89\u5168\u7684\u4fe1\u606f\u4ea4\u6362"},"content":{"rendered":"\n<p><s>\u5176\u5b9e\u5c31\u662f\u624b\u52a8SSL\uff0c\u8fd8\u6ca1\u6709CA\u5e2e\u4f60\u9a8c\u8bc1\uff08\u867d\u7136\u53ef\u4ee5\u52a0\u4e0a\u8fd9\u6b65\uff09<\/s><br>\u4e8e\u547d\u4ee4\u884c\uff0cLinux\u73af\u5883\uff0c\u5b89\u88c5\u4e86OpenSSL\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u751f\u6210\u5bc6\u94a5<\/h2>\n\n\n\n<p>\u5728\u5f53\u524d\u76ee\u5f55\u751f\u6210\u7528\u4e8e\u52a0\u5bc6\u7684\u516c\u94a5\u548c\u89e3\u5bc6\u7684\u79c1\u94a5\uff0c\u5206\u522b\u4fdd\u5b58\u4e3apub.pem\u548ckey.pem\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><em>\u53ef\u4ee5\u6309\u9700\u9009\u62e92048\u6216\u66f4\u957f\u7684RSA\u5bc6\u94a5<\/em>\n$ <strong>openssl genrsa 1024 > key.pem\n<\/strong>$ <strong>openssl rsa -pubout -in key.pem > pub.pem<\/strong>\n\n<em>\u751f\u6210\u4e00\u4e2a\u7528\u4e8e\u5bf9\u79f0\u52a0\u5bc6\u7684\u5bc6\u94a5\uff08\u6c42md5sum\u53ea\u662f\u4e3a\u4e86\u8ba9\u5bc6\u94a5\u662f16\u8fdb\u5236\u6570\uff0c\u65b9\u4fbf\u8f93\u5165\uff0c\u4f46\u8fd9\u4e2ahash\u4e5f\u662f\u968f\u673a\u7684\u6765\u7740\uff09<\/em>\n$ <strong>head -c128 \/dev\/urandom | md5sum<\/strong><\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\u4ea4\u6362\u5bc6\u94a5<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code><em>\u52a0\u5bc6\u7528\u4e8e\u5bf9\u79f0\u52a0\u5bc6\u7684\u5bc6\u94a5\u201cSecret\u201d\uff0c\u4e4b\u540e\u4ee5base64\u5f62\u5f0f\u8f93\u51fa\uff0c\u8fd9\u4e2a\u53ef\u4ee5\u53d1\u7ed9\u5bf9\u65b9\u8fdb\u884c\u5bc6\u94a5\u4ea4\u6362\u4e86<\/em>\n$ <strong>echo Secret | openssl rsautl -encrypt -pubin -inkey pub.pem | base64<\/strong>\n<em>\u89e3\u5bc6\u52a0\u5bc6\u8fc7\u7684\u201cSecret\u201d<\/em>\n$ <strong>echo \"Encrypted Secret\" | base64 -d | openssl rsautl -decrypt -inkey private.pem<\/strong><\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\u5bf9\u79f0\u52a0\u5bc6\uff0c\u5f00\u59cb\u4ea4\u6d41<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code><em>\u6309\u9700\u9009\u62e9\u7b97\u6cd5\uff0c\u8fd9\u91cc\u662faes-128-cbc\uff0c\u4f1a\u8981\u6c42\u8f93\u5165\u5bc6\u94a5<\/em>\n$ <strong>echo Text | openssl enc -aes-128-cbc -pbkdf2 | base64<\/strong>\n<em>\u53ef\u4ee5\u6539\u4e3a openssl enc -aes-128-cbc -pbkdf2 -pass <strong>pass:Secret<\/strong>\u6216\u8005<strong>file:\u6587\u4ef6<\/strong>\uff0c\u8fd9\u6837\u5c31\u4e0d\u7528\u8f93\u5165\u5bc6\u94a5\u4e86<\/em>\n\n<em>\u89e3\u5bc6<\/em>\n$ <strong>echo \"Encrypted Text\" | base64 -d | openssl aes-128-cbc -pbkdf2 -d<\/strong><\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\u201c\u7528GPG\u4e0d\u5c31\u597d\u4e86\u5417\u201d<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code><em>\u751f\u6210\u5bc6\u94a5<\/em>\n$ <strong>gpg --gen-key<\/strong>\n<em>\u4e0a\u4f20\u5bc6\u94a5<\/em>\n$ <strong>gpg --send-keys <em>USERID<\/em><\/strong>\n\u67e5\u770b\u5bc6\u94a5\u7279\u5f81\n$ <strong>gpg --fingerprint <em>USERID<\/em><\/strong>\n<em>\u4e0b\u8f7d\uff08\u5bf9\u65b9\uff09<\/em>\n$ <strong>gpg --search-keys <em>FINGERPRINT<\/em><\/strong>\n<em>\u52a0\u5bc6\uff08\u5bf9\u65b9\uff09<\/em>\n$ <strong>echo Text | gpg --encrypt --recipient <em>USERID<\/em> | base64<\/strong>\n<em>\u89e3\u5bc6\uff08\u81ea\u5df1\uff09<\/em>\n$ <strong>echo \"Encrypted Text\" | base64 -d | gpg --decrypt<\/strong><\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u5176\u5b9e\u5c31\u662f\u624b\u52a8SSL\uff0c\u8fd8\u6ca1\u6709CA\u5e2e\u4f60\u9a8c\u8bc1\uff08\u867d\u7136\u53ef\u4ee5\u52a0&#8230;<\/p>\n<div class=\"more-link-wrapper\"><a class=\"more-link\" href=\"https:\/\/blog.messyghost.net\/?p=244\">Continue reading<span class=\"screen-reader-text\">\u5728\u4f7f\u7528\u4e0d\u4fe1\u4efb\u7684\u901a\u4fe1\u624b\u6bb5\u65f6\u8fdb\u884c\u5b89\u5168\u7684\u4fe1\u606f\u4ea4\u6362<\/span><\/a><\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[32,28,29],"class_list":["post-244","post","type-post","status-publish","format-standard","hentry","category-3","tag-gpg","tag-openssl-2","tag-29","entry"],"_links":{"self":[{"href":"https:\/\/blog.messyghost.net\/index.php?rest_route=\/wp\/v2\/posts\/244","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.messyghost.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.messyghost.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.messyghost.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.messyghost.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=244"}],"version-history":[{"count":5,"href":"https:\/\/blog.messyghost.net\/index.php?rest_route=\/wp\/v2\/posts\/244\/revisions"}],"predecessor-version":[{"id":282,"href":"https:\/\/blog.messyghost.net\/index.php?rest_route=\/wp\/v2\/posts\/244\/revisions\/282"}],"wp:attachment":[{"href":"https:\/\/blog.messyghost.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=244"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.messyghost.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=244"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.messyghost.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=244"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}