{"id":187842,"date":"2024-11-11T17:38:19","date_gmt":"2024-11-11T09:38:19","guid":{"rendered":"https:\/\/server.hk\/cnblog\/187842\/"},"modified":"2024-11-11T17:38:21","modified_gmt":"2024-11-11T09:38:21","slug":"%e6%95%b8%e6%93%9a%e5%ba%ab%e4%b8%ad%e9%87%8d%e8%a6%81%e5%ad%97%e6%ae%b5%e7%9a%84%e5%8a%a0%e5%af%86%e6%96%b9%e5%bc%8f%e8%88%87%e5%af%a6%e7%8f%be%e6%96%b9%e6%b3%95-%e6%95%b8%e6%93%9a%e5%ba%ab%e6%95%8f","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/187842\/","title":{"rendered":"\u6578\u64da\u5eab\u4e2d\u91cd\u8981\u5b57\u6bb5\u7684\u52a0\u5bc6\u65b9\u5f0f\u8207\u5be6\u73fe\u65b9\u6cd5 (\u6578\u64da\u5eab\u654f\u611f\u5b57\u6bb5\u52a0\u5bc6)"},"content":{"rendered":"<h1 id=\"%e6%95%b8%e6%93%9a%e5%ba%ab%e4%b8%ad%e9%87%8d%e8%a6%81%e5%ad%97%e6%ae%b5%e7%9a%84%e5%8a%a0%e5%af%86%e6%96%b9%e5%bc%8f%e8%88%87%e5%af%a6%e7%8f%be%e6%96%b9%e6%b3%95-%e6%95%b8%e6%93%9a%e5%ba%ab%e6%95%8f-yxxVKPaEwp\">\u6578\u64da\u5eab\u4e2d\u91cd\u8981\u5b57\u6bb5\u7684\u52a0\u5bc6\u65b9\u5f0f\u8207\u5be6\u73fe\u65b9\u6cd5 (\u6578\u64da\u5eab\u654f\u611f\u5b57\u6bb5\u52a0\u5bc6)<\/h1>\n<p>\u5728\u7576\u4eca\u6578\u64da\u9a45\u52d5\u7684\u4e16\u754c\u4e2d\uff0c\u6578\u64da\u5eab\u7684\u5b89\u5168\u6027\u8b8a\u5f97\u8d8a\u4f86\u8d8a\u91cd\u8981\u3002\u96a8\u8457\u6578\u64da\u6d29\u9732\u4e8b\u4ef6\u7684\u983b\u7e41\u767c\u751f\uff0c\u4f01\u696d\u5fc5\u9808\u63a1\u53d6\u6709\u6548\u7684\u63aa\u65bd\u4f86\u4fdd\u8b77\u5176\u654f\u611f\u6578\u64da\u3002\u6578\u64da\u5eab\u4e2d\u7684\u654f\u611f\u5b57\u6bb5\uff0c\u5982\u7528\u6236\u5bc6\u78bc\u3001\u4fe1\u7528\u5361\u865f\u78bc\u548c\u500b\u4eba\u8eab\u4efd\u4fe1\u606f\uff0c\u5fc5\u9808\u9032\u884c\u52a0\u5bc6\u4ee5\u9632\u6b62\u672a\u7d93\u6388\u6b0a\u7684\u8a2a\u554f\u3002\u672c\u6587\u5c07\u63a2\u8a0e\u6578\u64da\u5eab\u4e2d\u91cd\u8981\u5b57\u6bb5\u7684\u52a0\u5bc6\u65b9\u5f0f\u53ca\u5176\u5be6\u73fe\u65b9\u6cd5\u3002<\/p>\n<h2 id=\"%e7%82%ba%e4%bb%80%e9%ba%bc%e9%9c%80%e8%a6%81%e5%8a%a0%e5%af%86%e6%95%8f%e6%84%9f%e5%ad%97%e6%ae%b5-yxxVKPaEwp\">\u70ba\u4ec0\u9ebc\u9700\u8981\u52a0\u5bc6\u654f\u611f\u5b57\u6bb5<\/h2>\n<p>\u6578\u64da\u5eab\u4e2d\u7684\u654f\u611f\u5b57\u6bb5\u5982\u679c\u672a\u7d93\u52a0\u5bc6\uff0c\u5c07\u9762\u81e8\u591a\u7a2e\u98a8\u96aa\uff0c\u5305\u62ec\u6578\u64da\u6d29\u9732\u3001\u8eab\u4efd\u76dc\u7aca\u548c\u5408\u898f\u6027\u554f\u984c\u3002\u6839\u64da\u300a\u901a\u7528\u6578\u64da\u4fdd\u8b77\u689d\u4f8b\u300b\uff08GDPR\uff09\u548c\u300a\u500b\u4eba\u8cc7\u6599\uff08\u79c1\u96b1\uff09\u689d\u4f8b\u300b\uff0c\u4f01\u696d\u6709\u8cac\u4efb\u4fdd\u8b77\u7528\u6236\u7684\u500b\u4eba\u4fe1\u606f\u3002\u52a0\u5bc6\u662f\u4e00\u7a2e\u6709\u6548\u7684\u4fdd\u8b77\u63aa\u65bd\uff0c\u80fd\u5920\u78ba\u4fdd\u5373\u4f7f\u6578\u64da\u88ab\u76dc\u53d6\uff0c\u653b\u64ca\u8005\u4e5f\u7121\u6cd5\u8f15\u6613\u89e3\u8b80\u3002<\/p>\n<h2 id=\"%e5%b8%b8%e8%a6%8b%e7%9a%84%e5%8a%a0%e5%af%86%e6%96%b9%e6%b3%95-yxxVKPaEwp\">\u5e38\u898b\u7684\u52a0\u5bc6\u65b9\u6cd5<\/h2>\n<h3 id=\"%e5%b0%8d%e7%a8%b1%e5%8a%a0%e5%af%86-yxxVKPaEwp\">\u5c0d\u7a31\u52a0\u5bc6<\/h3>\n<p>\u5c0d\u7a31\u52a0\u5bc6\u662f\u6307\u4f7f\u7528\u76f8\u540c\u7684\u5bc6\u9470\u9032\u884c\u52a0\u5bc6\u548c\u89e3\u5bc6\u3002\u9019\u7a2e\u65b9\u6cd5\u7684\u512a\u9ede\u662f\u901f\u5ea6\u5feb\uff0c\u4f46\u5bc6\u9470\u7684\u7ba1\u7406\u662f\u4e00\u500b\u6311\u6230\u3002\u5e38\u898b\u7684\u5c0d\u7a31\u52a0\u5bc6\u7b97\u6cd5\u5305\u62ec\uff1a<\/p>\n<ul>\n<li>AES\uff08\u9ad8\u7d1a\u52a0\u5bc6\u6a19\u6e96\uff09<\/li>\n<li>DES\uff08\u6578\u64da\u52a0\u5bc6\u6a19\u6e96\uff09<\/li>\n<li>3DES\uff08\u4e09\u91cd\u6578\u64da\u52a0\u5bc6\u6a19\u6e96\uff09<\/li>\n<\/ul>\n<p>\u4ee5\u4e0b\u662f\u4e00\u500b\u4f7f\u7528AES\u9032\u884c\u52a0\u5bc6\u7684\u7c21\u55ae\u793a\u4f8b\uff1a<\/p>\n<pre><code>\nfrom Crypto.Cipher import AES\nimport base64\n\ndef encrypt(plain_text, key):\n    cipher = AES.new(key.encode('utf-8'), AES.MODE_EAX)\n    ciphertext, tag = cipher.encrypt_and_digest(plain_text.encode('utf-8'))\n    return base64.b64encode(cipher.nonce + tag + ciphertext).decode('utf-8')\n\nkey = 'thisisaverysecret'\nplain_text = 'Sensitive Data'\nencrypted_text = encrypt(plain_text, key)\nprint(encrypted_text)\n<\/code><\/pre>\n<h3 id=\"%e9%9d%9e%e5%b0%8d%e7%a8%b1%e5%8a%a0%e5%af%86-yxxVKPaEwp\">\u975e\u5c0d\u7a31\u52a0\u5bc6<\/h3>\n<p>\u975e\u5c0d\u7a31\u52a0\u5bc6\u4f7f\u7528\u4e00\u5c0d\u5bc6\u9470\uff1a\u516c\u9470\u548c\u79c1\u9470\u3002\u516c\u9470\u7528\u65bc\u52a0\u5bc6\u6578\u64da\uff0c\u800c\u79c1\u9470\u7528\u65bc\u89e3\u5bc6\u3002\u9019\u7a2e\u65b9\u6cd5\u7684\u512a\u9ede\u662f\u5bc6\u9470\u7ba1\u7406\u66f4\u70ba\u5b89\u5168\uff0c\u4f46\u901f\u5ea6\u76f8\u5c0d\u8f03\u6162\u3002\u5e38\u898b\u7684\u975e\u5c0d\u7a31\u52a0\u5bc6\u7b97\u6cd5\u5305\u62ec\uff1a<\/p>\n<ul>\n<li>RSA<\/li>\n<li>DSA\uff08\u6578\u5b57\u7c3d\u540d\u7b97\u6cd5\uff09<\/li>\n<\/ul>\n<p>\u4ee5\u4e0b\u662f\u4e00\u500b\u4f7f\u7528RSA\u9032\u884c\u52a0\u5bc6\u7684\u7c21\u55ae\u793a\u4f8b\uff1a<\/p>\n<pre><code>\nfrom Crypto.PublicKey import RSA\nfrom Crypto.Cipher import PKCS1_OAEP\nimport base64\n\ndef encrypt(plain_text, public_key):\n    cipher = PKCS1_OAEP.new(public_key)\n    encrypted = cipher.encrypt(plain_text.encode('utf-8'))\n    return base64.b64encode(encrypted).decode('utf-8')\n\nkey = RSA.generate(2048)\npublic_key = key.publickey()\nplain_text = 'Sensitive Data'\nencrypted_text = encrypt(plain_text, public_key)\nprint(encrypted_text)\n<\/code><\/pre>\n<h2 id=\"%e6%95%b8%e6%93%9a%e5%ba%ab%e4%b8%ad%e7%9a%84%e5%8a%a0%e5%af%86%e5%af%a6%e7%8f%be-yxxVKPaEwp\">\u6578\u64da\u5eab\u4e2d\u7684\u52a0\u5bc6\u5be6\u73fe<\/h2>\n<p>\u5728\u6578\u64da\u5eab\u4e2d\u5be6\u73fe\u654f\u611f\u5b57\u6bb5\u7684\u52a0\u5bc6\u901a\u5e38\u6d89\u53ca\u4ee5\u4e0b\u6b65\u9a5f\uff1a<\/p>\n<ol>\n<li><strong>\u9078\u64c7\u52a0\u5bc6\u7b97\u6cd5\uff1a<\/strong>\u6839\u64da\u6578\u64da\u7684\u654f\u611f\u6027\u548c\u6027\u80fd\u9700\u6c42\u9078\u64c7\u5408\u9069\u7684\u52a0\u5bc6\u7b97\u6cd5\u3002<\/li>\n<li><strong>\u751f\u6210\u5bc6\u9470\uff1a<\/strong>\u78ba\u4fdd\u5bc6\u9470\u7684\u5b89\u5168\u5b58\u5132\u548c\u7ba1\u7406\u3002<\/li>\n<li><strong>\u52a0\u5bc6\u6578\u64da\uff1a<\/strong>\u5728\u5c07\u6578\u64da\u5beb\u5165\u6578\u64da\u5eab\u4e4b\u524d\u9032\u884c\u52a0\u5bc6\u3002<\/li>\n<li><strong>\u89e3\u5bc6\u6578\u64da\uff1a<\/strong>\u5728\u9700\u8981\u4f7f\u7528\u6578\u64da\u6642\u9032\u884c\u89e3\u5bc6\u3002<\/li>\n<\/ol>\n<h2 id=\"%e7%b5%90%e8%ab%96-yxxVKPaEwp\">\u7d50\u8ad6<\/h2>\n<p>\u6578\u64da\u5eab\u4e2d\u7684\u654f\u611f\u5b57\u6bb5\u52a0\u5bc6\u662f\u4fdd\u8b77\u6578\u64da\u5b89\u5168\u7684\u91cd\u8981\u63aa\u65bd\u3002\u9078\u64c7\u5408\u9069\u7684\u52a0\u5bc6\u65b9\u6cd5\u548c\u7b97\u6cd5\uff0c\u4e26\u59a5\u5584\u7ba1\u7406\u5bc6\u9470\uff0c\u662f\u78ba\u4fdd\u6578\u64da\u5b89\u5168\u7684\u95dc\u9375\u3002\u96a8\u8457\u6280\u8853\u7684\u767c\u5c55\uff0c\u4f01\u696d\u61c9\u6301\u7e8c\u95dc\u6ce8\u6578\u64da\u5b89\u5168\u7684\u6700\u4f73\u5be6\u8e10\uff0c\u4ee5\u61c9\u5c0d\u4e0d\u65b7\u8b8a\u5316\u7684\u5a01\u8105\u3002<\/p>\n<p>\u5982\u9700\u4e86\u89e3\u66f4\u591a\u6709\u95dc\u6578\u64da\u5eab\u5b89\u5168\u548c\u5176\u4ed6\u76f8\u95dc\u6280\u8853\u7684\u4fe1\u606f\uff0c\u8acb\u8a2a\u554f\u6211\u5011\u7684\u7db2\u7ad9 <a href=\"https:\/\/server.hk\">Server.HK<\/a>\uff0c\u6211\u5011\u63d0\u4f9b\u5404\u7a2e <a href=\"https:\/\/server.hk\">VPS<\/a> \u89e3\u6c7a\u65b9\u6848\uff0c\u5e6b\u52a9\u60a8\u4fdd\u8b77\u60a8\u7684\u6578\u64da\u548c\u61c9\u7528\u7a0b\u5e8f\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u63a2\u7d22\u6578\u64da\u5eab\u4e2d\u91cd\u8981\u5b57\u6bb5\u7684\u52a0\u5bc6\u65b9\u5f0f\u8207\u5be6\u73fe\u65b9\u6cd5\uff0c\u4fdd\u969c\u654f\u611f\u6578\u64da\u5b89\u5168\uff0c\u9632\u6b62\u672a\u6388\u6b0a\u8a2a\u554f\u3002<\/p>\n","protected":false},"author":0,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[101],"tags":[],"class_list":["post-187842","post","type-post","status-publish","format-standard","hentry","category-database"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/187842","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/types\/post"}],"replies":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/comments?post=187842"}],"version-history":[{"count":1,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/187842\/revisions"}],"predecessor-version":[{"id":187843,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/187842\/revisions\/187843"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=187842"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=187842"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=187842"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}