{"id":190170,"date":"2024-11-12T10:21:21","date_gmt":"2024-11-12T02:21:21","guid":{"rendered":"https:\/\/server.hk\/cnblog\/190170\/"},"modified":"2024-11-12T10:21:23","modified_gmt":"2024-11-12T02:21:23","slug":"%e7%b6%b2%e7%ab%99%e5%ae%89%e5%85%a8%e5%8d%87%e7%b4%9a%ef%bc%8c%e6%95%b8%e6%93%9a%e5%ba%ab%e5%8a%a0%e5%af%86%e6%8e%a5%e5%8f%a3%e4%bf%9d%e9%9a%9c%e6%82%a8%e7%9a%84%e6%95%b8%e6%93%9a%e5%ae%89%e5%85%a8","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/190170\/","title":{"rendered":"\u7db2\u7ad9\u5b89\u5168\u5347\u7d1a\uff0c\u6578\u64da\u5eab\u52a0\u5bc6\u63a5\u53e3\u4fdd\u969c\u60a8\u7684\u6578\u64da\u5b89\u5168\uff01 (\u7db2\u7ad9 \u6578\u64da\u5eab\u52a0\u5bc6\u63a5\u53e3)"},"content":{"rendered":"<h1 id=\"%e7%b6%b2%e7%ab%99%e5%ae%89%e5%85%a8%e5%8d%87%e7%b4%9a%ef%bc%8c%e6%95%b8%e6%93%9a%e5%ba%ab%e5%8a%a0%e5%af%86%e6%8e%a5%e5%8f%a3%e4%bf%9d%e9%9a%9c%e6%82%a8%e7%9a%84%e6%95%b8%e6%93%9a%e5%ae%89%e5%85%a8-dcwNCNGfAs\">\u7db2\u7ad9\u5b89\u5168\u5347\u7d1a\uff0c\u6578\u64da\u5eab\u52a0\u5bc6\u63a5\u53e3\u4fdd\u969c\u60a8\u7684\u6578\u64da\u5b89\u5168\uff01<\/h1>\n<p>\u5728\u7576\u4eca\u6578\u5b57\u5316\u7684\u6642\u4ee3\uff0c\u7db2\u7ad9\u5b89\u5168\u5df2\u6210\u70ba\u4f01\u696d\u548c\u500b\u4eba\u7528\u6236\u6700\u95dc\u6ce8\u7684\u8b70\u984c\u4e4b\u4e00\u3002\u96a8\u8457\u7db2\u7d61\u653b\u64ca\u7684\u983b\u7e41\u767c\u751f\uff0c\u6578\u64da\u6d29\u9732\u4e8b\u4ef6\u5c64\u51fa\u4e0d\u7aae\uff0c\u5982\u4f55\u4fdd\u8b77\u7db2\u7ad9\u53ca\u5176\u6578\u64da\u5eab\u7684\u5b89\u5168\u6210\u70ba\u4e86\u91cd\u4e2d\u4e4b\u91cd\u3002\u672c\u6587\u5c07\u63a2\u8a0e\u6578\u64da\u5eab\u52a0\u5bc6\u63a5\u53e3\u7684\u6982\u5ff5\u53ca\u5176\u5728\u7db2\u7ad9\u5b89\u5168\u4e2d\u7684\u91cd\u8981\u6027\u3002<\/p>\n<h2 id=\"%e6%95%b8%e6%93%9a%e5%ba%ab%e5%8a%a0%e5%af%86%e7%9a%84%e5%bf%85%e8%a6%81%e6%80%a7-dcwNCNGfAs\">\u6578\u64da\u5eab\u52a0\u5bc6\u7684\u5fc5\u8981\u6027<\/h2>\n<p>\u6578\u64da\u5eab\u662f\u7db2\u7ad9\u904b\u884c\u7684\u6838\u5fc3\uff0c\u5b58\u5132\u8457\u7528\u6236\u4fe1\u606f\u3001\u4ea4\u6613\u8a18\u9304\u53ca\u5176\u4ed6\u654f\u611f\u6578\u64da\u3002\u82e5\u6578\u64da\u5eab\u906d\u5230\u653b\u64ca\uff0c\u9ed1\u5ba2\u53ef\u80fd\u6703\u7aca\u53d6\u3001\u7be1\u6539\u6216\u522a\u9664\u6578\u64da\uff0c\u5c0d\u4f01\u696d\u9020\u6210\u56b4\u91cd\u640d\u5931\u3002\u56e0\u6b64\uff0c\u5c0d\u6578\u64da\u5eab\u9032\u884c\u52a0\u5bc6\u662f\u4fdd\u8b77\u6578\u64da\u5b89\u5168\u7684\u91cd\u8981\u63aa\u65bd\u4e4b\u4e00\u3002<\/p>\n<h3 id=\"%e6%95%b8%e6%93%9a%e5%ba%ab%e5%8a%a0%e5%af%86%e7%9a%84%e5%b7%a5%e4%bd%9c%e5%8e%9f%e7%90%86-dcwNCNGfAs\">\u6578\u64da\u5eab\u52a0\u5bc6\u7684\u5de5\u4f5c\u539f\u7406<\/h3>\n<p>\u6578\u64da\u5eab\u52a0\u5bc6\u662f\u5c07\u6578\u64da\u8f49\u63db\u70ba\u4e0d\u53ef\u8b80\u7684\u683c\u5f0f\uff0c\u53ea\u6709\u64c1\u6709\u6b63\u78ba\u5bc6\u9470\u7684\u7528\u6236\u624d\u80fd\u89e3\u5bc6\u4e26\u8a2a\u554f\u6578\u64da\u3002\u9019\u4e00\u904e\u7a0b\u901a\u5e38\u6d89\u53ca\u4ee5\u4e0b\u5e7e\u500b\u6b65\u9a5f\uff1a<\/p>\n<ul>\n<li><strong>\u6578\u64da\u52a0\u5bc6\uff1a<\/strong>\u5728\u6578\u64da\u5beb\u5165\u6578\u64da\u5eab\u4e4b\u524d\uff0c\u4f7f\u7528\u52a0\u5bc6\u7b97\u6cd5\u5c07\u5176\u8f49\u63db\u70ba\u5bc6\u6587\u3002<\/li>\n<li><strong>\u5bc6\u9470\u7ba1\u7406\uff1a<\/strong>\u5b89\u5168\u5730\u5b58\u5132\u548c\u7ba1\u7406\u52a0\u5bc6\u5bc6\u9470\uff0c\u78ba\u4fdd\u53ea\u6709\u6388\u6b0a\u7528\u6236\u53ef\u4ee5\u8a2a\u554f\u3002<\/li>\n<li><strong>\u6578\u64da\u89e3\u5bc6\uff1a<\/strong>\u7576\u9700\u8981\u8a2a\u554f\u6578\u64da\u6642\uff0c\u4f7f\u7528\u6b63\u78ba\u7684\u5bc6\u9470\u5c07\u5bc6\u6587\u8f49\u63db\u56de\u53ef\u8b80\u683c\u5f0f\u3002<\/li>\n<\/ul>\n<h2 id=\"%e6%95%b8%e6%93%9a%e5%ba%ab%e5%8a%a0%e5%af%86%e6%8e%a5%e5%8f%a3%e7%9a%84%e5%af%a6%e7%8f%be-dcwNCNGfAs\">\u6578\u64da\u5eab\u52a0\u5bc6\u63a5\u53e3\u7684\u5be6\u73fe<\/h2>\n<p>\u70ba\u4e86\u5be6\u73fe\u6578\u64da\u5eab\u7684\u52a0\u5bc6\uff0c\u958b\u767c\u8005\u53ef\u4ee5\u4f7f\u7528\u591a\u7a2e\u52a0\u5bc6\u63a5\u53e3\u548c\u5eab\u3002\u4ee5\u4e0b\u662f\u4e00\u4e9b\u5e38\u898b\u7684\u52a0\u5bc6\u7b97\u6cd5\u53ca\u5176\u5be6\u73fe\u793a\u4f8b\uff1a<\/p>\n<h3 id=\"aes%e5%8a%a0%e5%af%86%e7%a4%ba%e4%be%8b-dcwNCNGfAs\">AES\u52a0\u5bc6\u793a\u4f8b<\/h3>\n<pre><code>\nimport base64\nfrom Crypto.Cipher import AES\nfrom Crypto.Util.Padding import pad, unpad\n\ndef encrypt(plain_text, key):\n    cipher = AES.new(key, AES.MODE_CBC)\n    ct_bytes = cipher.encrypt(pad(plain_text.encode(), AES.block_size))\n    iv = base64.b64encode(cipher.iv).decode('utf-8')\n    ct = base64.b64encode(ct_bytes).decode('utf-8')\n    return iv, ct\n\ndef decrypt(iv, ct, key):\n    iv = base64.b64decode(iv)\n    ct = base64.b64decode(ct)\n    cipher = AES.new(key, AES.MODE_CBC, iv)\n    pt = unpad(cipher.decrypt(ct), AES.block_size).decode('utf-8')\n    return pt\n\n# \u4f7f\u7528\u793a\u4f8b\nkey = b'Sixteen byte key'\niv, ct = encrypt(\"Hello World!\", key)\nprint(\"IV:\", iv)\nprint(\"Cipher Text:\", ct)\nprint(\"Decrypted:\", decrypt(iv, ct, key))\n<\/code><\/pre>\n<p>\u5728\u4e0a\u8ff0\u793a\u4f8b\u4e2d\uff0c\u6211\u5011\u4f7f\u7528\u4e86AES\uff08\u9ad8\u7d1a\u52a0\u5bc6\u6a19\u6e96\uff09\u7b97\u6cd5\u4f86\u52a0\u5bc6\u548c\u89e3\u5bc6\u6578\u64da\u3002\u9019\u7a2e\u65b9\u6cd5\u4e0d\u50c5\u5b89\u5168\uff0c\u9084\u80fd\u6709\u6548\u4fdd\u8b77\u6578\u64da\u7684\u5b8c\u6574\u6027\u3002<\/p>\n<h2 id=\"%e6%95%b8%e6%93%9a%e5%ba%ab%e5%8a%a0%e5%af%86%e7%9a%84%e6%9c%80%e4%bd%b3%e5%af%a6%e8%b8%90-dcwNCNGfAs\">\u6578\u64da\u5eab\u52a0\u5bc6\u7684\u6700\u4f73\u5be6\u8e10<\/h2>\n<p>\u70ba\u4e86\u78ba\u4fdd\u6578\u64da\u5eab\u52a0\u5bc6\u7684\u6709\u6548\u6027\uff0c\u4ee5\u4e0b\u662f\u4e00\u4e9b\u6700\u4f73\u5be6\u8e10\uff1a<\/p>\n<ul>\n<li><strong>\u5b9a\u671f\u66f4\u65b0\u52a0\u5bc6\u7b97\u6cd5\uff1a<\/strong>\u96a8\u8457\u6280\u8853\u7684\u9032\u6b65\uff0c\u820a\u7684\u52a0\u5bc6\u7b97\u6cd5\u53ef\u80fd\u6703\u8b8a\u5f97\u4e0d\u518d\u5b89\u5168\uff0c\u56e0\u6b64\u61c9\u5b9a\u671f\u8a55\u4f30\u548c\u66f4\u65b0\u4f7f\u7528\u7684\u52a0\u5bc6\u6280\u8853\u3002<\/li>\n<li><strong>\u5be6\u65bd\u591a\u5c64\u5b89\u5168\u63aa\u65bd\uff1a<\/strong>\u9664\u4e86\u6578\u64da\u5eab\u52a0\u5bc6\uff0c\u9084\u61c9\u7d50\u5408\u9632\u706b\u7246\u3001\u5165\u4fb5\u6aa2\u6e2c\u7cfb\u7d71\u7b49\u5176\u4ed6\u5b89\u5168\u63aa\u65bd\uff0c\u5f62\u6210\u591a\u5c64\u9632\u8b77\u3002<\/li>\n<li><strong>\u9032\u884c\u5b89\u5168\u5be9\u8a08\uff1a<\/strong>\u5b9a\u671f\u5c0d\u6578\u64da\u5eab\u9032\u884c\u5b89\u5168\u5be9\u8a08\uff0c\u6aa2\u67e5\u6f5b\u5728\u7684\u5b89\u5168\u6f0f\u6d1e\u548c\u98a8\u96aa\u3002<\/li>\n<\/ul>\n<h2 id=\"%e7%b5%90%e8%ab%96-dcwNCNGfAs\">\u7d50\u8ad6<\/h2>\n<p>\u96a8\u8457\u7db2\u7d61\u5b89\u5168\u5a01\u8105\u7684\u589e\u52a0\uff0c\u7db2\u7ad9\u6578\u64da\u5eab\u7684\u52a0\u5bc6\u8b8a\u5f97\u6108\u767c\u91cd\u8981\u3002\u901a\u904e\u5be6\u65bd\u6578\u64da\u5eab\u52a0\u5bc6\u63a5\u53e3\uff0c\u4f01\u696d\u53ef\u4ee5\u6709\u6548\u4fdd\u8b77\u5176\u654f\u611f\u6578\u64da\uff0c\u964d\u4f4e\u6578\u64da\u6d29\u9732\u7684\u98a8\u96aa\u3002\u9078\u64c7\u5408\u9069\u7684\u52a0\u5bc6\u7b97\u6cd5\u548c\u5be6\u65bd\u6700\u4f73\u5be6\u8e10\uff0c\u5c07\u6709\u52a9\u65bc\u63d0\u5347\u7db2\u7ad9\u7684\u6574\u9ad4\u5b89\u5168\u6027\u3002<\/p>\n<p>\u5982\u9700\u4e86\u89e3\u66f4\u591a\u6709\u95dc\u7db2\u7ad9\u5b89\u5168\u53ca\u6578\u64da\u5eab\u52a0\u5bc6\u7684\u8cc7\u8a0a\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\u5b89\u5168\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u63d0\u5347\u7db2\u7ad9\u5b89\u5168\uff0c\u900f\u904e\u6578\u64da\u5eab\u52a0\u5bc6\u63a5\u53e3\u78ba\u4fdd\u60a8\u7684\u6578\u64da\u5b89\u5168\u7121\u865e\uff0c\u4fdd\u8b77\u654f\u611f\u4fe1\u606f\uff0c\u589e\u5f37\u7528\u6236\u4fe1\u4efb\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-190170","post","type-post","status-publish","format-standard","hentry","category-database"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/190170","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=190170"}],"version-history":[{"count":1,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/190170\/revisions"}],"predecessor-version":[{"id":190171,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/190170\/revisions\/190171"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=190170"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=190170"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=190170"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}