{"id":48,"date":"2026-03-02T00:59:12","date_gmt":"2026-03-01T16:59:12","guid":{"rendered":"https:\/\/nangao.site\/?p=48"},"modified":"2026-03-09T01:58:52","modified_gmt":"2026-03-08T17:58:52","slug":"%e6%b7%b1%e5%85%a5%e8%a7%a3%e6%9e%90-c-%e8%af%ad%e8%a8%80%e5%ae%a2%e6%88%b7%e7%ab%af%e4%b8%8e-php-%e5%90%8e%e7%ab%af%e7%9a%84%e5%ae%89%e5%85%a8%e5%af%86%e9%92%a5%e4%ba%a4%e6%8d%a2%e4%b8%8e%e5%8a%a0","status":"publish","type":"post","link":"https:\/\/nangao.site\/index.php\/2026\/03\/02\/%e6%b7%b1%e5%85%a5%e8%a7%a3%e6%9e%90-c-%e8%af%ad%e8%a8%80%e5%ae%a2%e6%88%b7%e7%ab%af%e4%b8%8e-php-%e5%90%8e%e7%ab%af%e7%9a%84%e5%ae%89%e5%85%a8%e5%af%86%e9%92%a5%e4%ba%a4%e6%8d%a2%e4%b8%8e%e5%8a%a0\/","title":{"rendered":"\u6df1\u5165\u89e3\u6790 C \u8bed\u8a00\u5ba2\u6237\u7aef\u4e0e PHP \u540e\u7aef\u7684\u5b89\u5168\u5bc6\u94a5\u4ea4\u6362\u4e0e\u52a0\u5bc6\u901a\u4fe1\u673a\u5236"},"content":{"rendered":"\n<p>\u5728\u5f53\u4eca\u7684\u7f51\u7edc\u901a\u4fe1\u4e2d\uff0c\u6570\u636e\u7684\u5b89\u5168\u6027\u81f3\u5173\u91cd\u8981\u3002\u672c\u6587\u5c06\u6df1\u5165\u63a2\u8ba8\u4e00\u4e2a\u57fa\u4e8e C \u8bed\u8a00\u5ba2\u6237\u7aef\uff08\u8bbe\u5907\u7aef\uff09\u4e0e PHP \u540e\u7aef\u67b6\u6784\u7684\u5b9e\u6218\u6848\u4f8b\uff0c\u89e3\u6790\u5176\u5982\u4f55\u5229\u7528<strong>ECDH\uff08Elliptic Curve Diffie-Hellman\uff09<\/strong>&nbsp;\u7b97\u6cd5\u8fdb\u884c\u5b89\u5168\u7684\u5bc6\u94a5\u534f\u5546\uff0c\u5e76\u7ed3\u5408 <strong>AES-256-CBC<\/strong> \u5bf9\u79f0\u52a0\u5bc6\u7b97\u6cd5\u4fdd\u969c\u6570\u636e\u4f20\u8f93\u7684\u673a\u5bc6\u6027\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">1.<strong>\u6838\u5fc3\u6982\u5ff5\uff1a\u4e24\u5927\u795e\u5668\u7684\u914d\u5408<\/strong><\/h2>\n\n\n\n<p>\u4e3a\u4e86\u5b9e\u73b0\u5b89\u5168\u901a\u4fe1\uff0c\u6211\u4eec\u9700\u8981\u4e24\u79cd\u52a0\u5bc6\u6280\u672f\u7684\u914d\u5408\uff0c<strong>\u5bf9\u79f0\u52a0\u5bc6 (AES)<\/strong>\u548c<strong>\u5bc6\u94a5\u534f\u5546 (ECDH)<\/strong><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">1.1 \u4ec0\u4e48\u662fAES\u52a0\u5bc6\uff1f<\/h3>\n\n\n\n<p>\u7b80\u6613\u6765\u8bf4\uff0c\u5c31\u662f\u4f60\u8981\u7ed9\u4f60\u7684\u670b\u53cb\u5bc4\u4e00\u4e2a\u88c5\u6ee1\u673a\u5bc6\u7684\u7bb1\u5b50\uff0c\u5982\u679c\u4e0d\u5b89\u88c5\u9501\uff0c\u5c31\u4f1a\u88ab\u5feb\u9012\u5458\u5077\u770b\uff0c\u4e5f\u5c31\u662f\u660e\u6587\u4f20\u8f93\uff0c\u800cAES\u5c31\u662f\u7ed9\u8fd9\u4e2a\u7bb1\u5b50\u52a0\u4e0a\u4e00\u628a\u9501\uff0c\u4f60\u548c\u4f60\u670b\u53cb\u9700\u8981\u76f8\u540c\u94a5\u5319\u624d\u80fd\u6253\u5f00<\/p>\n\n\n\n<p>\u603b\u7ed3\u4e00\u4e0b<\/p>\n\n\n\n<div class=\"wp-block-group has-pale-cyan-blue-background-color has-background has-medium-font-size is-vertical is-layout-flex wp-container-core-group-is-layout-8cf370e7 wp-block-group-is-layout-flex\">\n<p><strong>\u52a0\u5bc6<\/strong>\uff1a\u4f60\u7528\u4e00\u628a\u94a5\u5319\u628a\u7bb1\u5b50\u9501\u4e0a\u3002<\/p>\n\n\n\n<p><strong>\u4f20\u8f93<\/strong>\uff1a\u9501\u597d\u7684\u7bb1\u5b50\uff08\u5bc6\u6587\uff09\u901a\u8fc7\u5feb\u9012\u8f66\uff08\u4e92\u8054\u7f51\uff09\u8fd0\u8f93\u3002<\/p>\n\n\n\n<p><strong>\u89e3\u5bc6<\/strong>\uff1a\u670b\u53cb\u6536\u5230\u7bb1\u5b50\u540e\uff0c\u5fc5\u987b\u7528<strong>\u540c\u4e00\u628a\u94a5\u5319<\/strong>\u624d\u80fd\u6253\u5f00\u3002<\/p>\n<\/div>\n\n\n\n<p><\/p>\n\n\n\n<p><strong>\u8fd9\u5c31\u4f1a\u6709\u4e2a\u5173\u952e\u70b9\uff0c\u52a0\u5bc6\u548c\u89e3\u5bc6\u662f\u540c\u4e00\u628a\u94a5\u5319\uff0c\u5982\u679c\u94a5\u5319\u4e22\u5931\uff0c\u7bb1\u5b50\u5c31\u4e0d\u5b89\u5168<\/strong><\/p>\n\n\n\n<svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" viewBox=\"0 0 800 400\">\n  <!-- Background -->\n  <rect width=\"800\" height=\"400\" fill=\"#f8f9fa\" rx=\"10\" ry=\"10\"\/>\n  \n  <!-- Title -->\n  <text x=\"400\" y=\"40\" font-family=\"Arial, sans-serif\" font-size=\"24\" text-anchor=\"middle\" font-weight=\"bold\" fill=\"#333\">AES \u5bf9\u79f0\u52a0\u5bc6\u539f\u7406\u6d41\u7a0b<\/text>\n\n  <!-- Encryption Side -->\n  <g transform=\"translate(50, 80)\">\n    <text x=\"100\" y=\"-10\" font-family=\"Arial\" font-size=\"18\" text-anchor=\"middle\" fill=\"#555\">\u53d1\u9001\u65b9 (Client)<\/text>\n    \n    <!-- Plaintext -->\n    <rect x=\"50\" y=\"20\" width=\"100\" height=\"60\" fill=\"#e3f2fd\" stroke=\"#2196f3\" stroke-width=\"2\" rx=\"5\"\/>\n    <text x=\"100\" y=\"55\" font-family=\"Arial\" font-size=\"14\" text-anchor=\"middle\">\u660e\u6587\u6570\u636e<\/text>\n    \n    <!-- Arrow -->\n    <line x1=\"100\" y1=\"80\" x2=\"100\" y2=\"120\" stroke=\"#666\" stroke-width=\"2\" marker-end=\"url(#arrow)\"\/>\n    \n    <!-- Key Input -->\n    <path d=\"M160 140 L120 140\" stroke=\"#f44336\" stroke-width=\"2\" stroke-dasharray=\"5,5\"\/>\n    <text x=\"180\" y=\"145\" font-family=\"Arial\" font-size=\"12\" fill=\"#d32f2f\">\u5bc6\u94a5 (Key)<\/text>\n    \n    <!-- Encryption Box -->\n    <rect x=\"50\" y=\"120\" width=\"100\" height=\"60\" fill=\"#ffecb3\" stroke=\"#ffc107\" stroke-width=\"2\" rx=\"5\"\/>\n    <text x=\"100\" y=\"145\" font-family=\"Arial\" font-size=\"14\" text-anchor=\"middle\" font-weight=\"bold\">AES \u52a0\u5bc6\u7b97\u6cd5<\/text>\n    <text x=\"100\" y=\"165\" font-family=\"Arial\" font-size=\"10\" text-anchor=\"middle\" fill=\"#666\">(\u6df7\u5408\/\u7f6e\u6362)<\/text>\n    \n    <!-- Arrow -->\n    <line x1=\"100\" y1=\"180\" x2=\"100\" y2=\"220\" stroke=\"#666\" stroke-width=\"2\" marker-end=\"url(#arrow)\"\/>\n    \n    <!-- Ciphertext -->\n    <rect x=\"50\" y=\"220\" width=\"100\" height=\"60\" fill=\"#e0e0e0\" stroke=\"#757575\" stroke-width=\"2\" rx=\"5\"\/>\n    <text x=\"100\" y=\"255\" font-family=\"Arial\" font-size=\"14\" text-anchor=\"middle\">\u5bc6\u6587 (\u4e71\u7801)<\/text>\n  <\/g>\n\n  <!-- Transmission -->\n  <g transform=\"translate(300, 200)\">\n    <line x1=\"0\" y1=\"0\" x2=\"200\" y2=\"0\" stroke=\"#333\" stroke-width=\"3\" stroke-dasharray=\"10,5\"\/>\n    <text x=\"100\" y=\"-10\" font-family=\"Arial\" font-size=\"14\" text-anchor=\"middle\" fill=\"#333\">\u4e92\u8054\u7f51\u4f20\u8f93 (\u4e0d\u5b89\u5168)<\/text>\n    <text x=\"100\" y=\"20\" font-family=\"Arial\" font-size=\"12\" text-anchor=\"middle\" fill=\"#d32f2f\">\u53ea\u6709\u5bc6\u6587\u88ab\u4f20\u8f93<\/text>\n  <\/g>\n\n  <!-- Decryption Side -->\n  <g transform=\"translate(550, 80)\">\n    <text x=\"100\" y=\"-10\" font-family=\"Arial\" font-size=\"18\" text-anchor=\"middle\" fill=\"#555\">\u63a5\u6536\u65b9 (Server)<\/text>\n    \n    <!-- Ciphertext -->\n    <rect x=\"50\" y=\"220\" width=\"100\" height=\"60\" fill=\"#e0e0e0\" stroke=\"#757575\" stroke-width=\"2\" rx=\"5\"\/>\n    <text x=\"100\" y=\"255\" font-family=\"Arial\" font-size=\"14\" text-anchor=\"middle\">\u5bc6\u6587 (\u4e71\u7801)<\/text>\n    \n    <!-- Arrow -->\n    <line x1=\"100\" y1=\"220\" x2=\"100\" y2=\"180\" stroke=\"#666\" stroke-width=\"2\" marker-end=\"url(#arrow-up)\"\/>\n    \n    <!-- Key Input -->\n    <path d=\"M40 150 L80 150\" stroke=\"#f44336\" stroke-width=\"2\" stroke-dasharray=\"5,5\"\/>\n    <text x=\"20\" y=\"155\" font-family=\"Arial\" font-size=\"12\" text-anchor=\"end\" fill=\"#d32f2f\">\u540c\u4e00\u628a\u5bc6\u94a5<\/text>\n    \n    <!-- Decryption Box -->\n    <rect x=\"50\" y=\"120\" width=\"100\" height=\"60\" fill=\"#ffecb3\" stroke=\"#ffc107\" stroke-width=\"2\" rx=\"5\"\/>\n    <text x=\"100\" y=\"155\" font-family=\"Arial\" font-size=\"14\" text-anchor=\"middle\" font-weight=\"bold\">AES \u89e3\u5bc6\u7b97\u6cd5<\/text>\n    \n    <!-- Arrow -->\n    <line x1=\"100\" y1=\"120\" x2=\"100\" y2=\"80\" stroke=\"#666\" stroke-width=\"2\" marker-end=\"url(#arrow-up)\"\/>\n    \n    <!-- Plaintext -->\n    <rect x=\"50\" y=\"20\" width=\"100\" height=\"60\" fill=\"#e3f2fd\" stroke=\"#2196f3\" stroke-width=\"2\" rx=\"5\"\/>\n    <text x=\"100\" y=\"55\" font-family=\"Arial\" font-size=\"14\" text-anchor=\"middle\">\u660e\u6587\u6570\u636e<\/text>\n  <\/g>\n\n  <!-- Definitions -->\n  <defs>\n    <marker id=\"arrow\" markerWidth=\"10\" markerHeight=\"10\" refX=\"9\" refY=\"3\" orient=\"auto\" markerUnits=\"strokeWidth\">\n      <path d=\"M0,0 L0,6 L9,3 z\" fill=\"#666\" \/>\n    <\/marker>\n    <marker id=\"arrow-up\" markerWidth=\"10\" markerHeight=\"10\" refX=\"9\" refY=\"3\" orient=\"auto\" markerUnits=\"strokeWidth\">\n      <path d=\"M0,0 L0,6 L9,3 z\" fill=\"#666\" \/>\n    <\/marker>\n  <\/defs>\n<\/svg>\n\n\n\n<h3 class=\"wp-block-heading\">1.2 \u4ec0\u4e48\u662fECDH\u7b97\u6cd5\uff1f<\/h3>\n\n\n\n<p>\u8fd8\u662f\u6309\u7b80\u5355\u7684\u8bb2\uff0c\u901a\u8fc7\u4e0a\u9762\u7684AES\u52a0\u5bc6\u8bb2\u89e3\uff0c\u4f1a\u610f\u8bc6\u5230\u4e00\u4e2a\u95ee\u9898\uff0c\u5c31\u662f\u4f60\u600e\u4e48\u628a\u90a3\u628a\u5f00\u7bb1\u5b50\u7684\u94a5\u5319\u5b89\u5168\u5730\u5bc4\u7ed9\u670b\u53cb\uff1f\u76f4\u63a5\u5bc4\u94a5\u5319\u80af\u5b9a\u4f1a\u88ab\u5077\u3002<\/p>\n\n\n\n<p>\u8fd9\u65f6\u5019ECDH\u5c31\u51fa\u73b0\u4e86\uff0c\u5b83\u5141\u8bb8\u4f60\u548c\u670b\u53cb\u5728\u4f17\u76ee\u777d\u777d\u4e4b\u4e0b\u4ea4\u6362\u4fe1\u606f\uff0c\u6700\u540e\u5404\u81ea\u53d8\u51fa\u4e00\u628a\u94a5\u5319\uff0c\u800c\u65c1\u8fb9\u7684\u5077\u770b\u8005\u5374\u53d8\u4e0d\u51fa\u6765\u3002<\/p>\n\n\n\n<p>\u90a3\u662f\u600e\u4e48\u5b9e\u73b0\u7684\u5462\uff0c\u7528\u989c\u6599\u6df7\u5408\u6765\u6bd4\u55bb<\/p>\n\n\n\n<div class=\"wp-block-group has-pale-cyan-blue-background-color has-background is-vertical is-content-justification-left is-layout-flex wp-container-core-group-is-layout-c0ca7d81 wp-block-group-is-layout-flex\">\n<p class=\"has-text-align-left\">1. &nbsp;<strong>\u79c1\u6709<\/strong>\uff1a\u5c0f\u660e\u9009\u4e86\u4e00\u79cd\u53ea\u6709\u5979\u77e5\u9053\u7684\u79c1\u5bc6\u989c\u8272\uff08\u6bd4\u5982\u7ea2\u8272\uff09\uff0c\u5c0f\u7ea2\u9009\u4e86\u53ea\u6709\u4ed6\u77e5\u9053\u7684\u79c1\u5bc6\u989c\u8272\uff08\u6bd4\u5982\u84dd\u8272\uff09\u3002<\/p>\n\n\n\n<p class=\"has-text-align-left\">2. &nbsp;<strong>\u516c\u5f00<\/strong>\uff1a\u4e24\u4eba\u7ea6\u5b9a\u597d\u4e00\u79cd\u516c\u5f00\u7684\u989c\u8272\uff08\u6bd4\u5982\u9ec4\u8272\uff09\uff0c\u8fd9\u4e2a\u989c\u8272\u8c01\u90fd\u53ef\u4ee5\u770b\u3002<\/p>\n\n\n\n<p class=\"has-text-align-left\">3. &nbsp;<strong>\u6df7\u5408<\/strong>\uff1a<\/p>\n\n\n\n<p class=\"has-text-align-left\">&nbsp; &nbsp; \u5c0f\u660e\u628a\u81ea\u5df1\u7684\u7ea2+\u9ec4\u6df7\u5408\uff0c\u5f97\u5230\u4e86\u6a59\u8272\u3002<\/p>\n\n\n\n<p class=\"has-text-align-left\">&nbsp; &nbsp; \u5c0f\u7ea2\u628a\u81ea\u5df1\u7684\u84dd+\u9ec4\u6df7\u5408\uff0c\u5f97\u5230\u4e86\u7eff\u8272\u3002<\/p>\n\n\n\n<p class=\"has-text-align-left\">4. &nbsp;<strong>\u4ea4\u6362<\/strong>\uff1a<\/p>\n\n\n\n<p class=\"has-text-align-left\">&nbsp; &nbsp; \u5c0f\u660e\u628a\u6a59\u8272\u5bc4\u7ed9\u5c0f\u7ea2\u3002<\/p>\n\n\n\n<p class=\"has-text-align-left\">&nbsp; &nbsp;\u5c0f\u7ea2\u628a\u7eff\u8272\u5bc4\u7ed9\u5c0f\u660e\u3002<\/p>\n\n\n\n<p class=\"has-text-align-left\">&nbsp; &nbsp; \uff08\u8fd9\u65f6\u5019\u5feb\u9012\u5458\u5077\u770b\u5230\u4e86\u6a59\u8272\u548c\u7eff\u8272\uff0c\u4f46\u4ed6\u4e0d\u77e5\u9053\u91cc\u9762\u52a0\u4e86\u591a\u5c11\u7ea2\u6216\u84dd\uff0c\u5f88\u96be\u5206\u79bb\u51fa\u6765\uff09\u3002<\/p>\n\n\n\n<p class=\"has-text-align-left\">5. &nbsp;<strong>\u751f\u6210\u94a5\u5319<\/strong>\uff1a<\/p>\n\n\n\n<p class=\"has-text-align-left\">&nbsp; &nbsp; \u5c0f\u660e\u6536\u5230\u7eff\u8272\uff0c\u6df7\u5165\u81ea\u5df1\u7684\u7ea2\u8272 =&gt; <strong>\u68d5\u8272<\/strong>\u3002<\/p>\n\n\n\n<p class=\"has-text-align-left\">&nbsp; &nbsp; \u5c0f\u7ea2\u6536\u5230\u6a59\u8272\uff0c\u6df7\u5165\u81ea\u5df1\u7684\u84dd\u8272 =&gt; <strong>\u68d5\u8272<\/strong>\u3002<\/p>\n\n\n\n<p class=\"has-text-align-left\">&nbsp; &nbsp; <strong>\u7ed3\u679c<\/strong>\uff1a\u4e24\u4eba\u624b\u91cc\u90fd\u662f\u68d5\u8272\uff01\u8fd9\u4e2a\u68d5\u8272\u5c31\u662f\u6700\u7ec8\u7684\u94a5\u5319\u3002<\/p>\n<\/div>\n\n\n\n<p><\/p>\n\n\n\n<svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" viewBox=\"0 0 800 500\">\n  <rect width=\"800\" height=\"500\" fill=\"#f8f9fa\" rx=\"10\" ry=\"10\"\/>\n  \n  <text x=\"400\" y=\"40\" font-family=\"Arial, sans-serif\" font-size=\"24\" text-anchor=\"middle\" font-weight=\"bold\" fill=\"#333\">ECDH \u5bc6\u94a5\u534f\u5546\u539f\u7406 (\u989c\u6599\u6df7\u5408\u6bd4\u55bb)<\/text>\n\n  <!-- Public Color -->\n  <g transform=\"translate(300, 60)\">\n    <rect x=\"50\" y=\"0\" width=\"100\" height=\"40\" fill=\"#FFFF99\" stroke=\"#999\" stroke-width=\"2\"\/>\n    <text x=\"100\" y=\"25\" font-family=\"Arial\" font-size=\"12\" text-anchor=\"middle\">\u516c\u5f00\u7684\u989c\u8272 (G)<\/text>\n    <text x=\"100\" y=\"55\" font-family=\"Arial\" font-size=\"10\" text-anchor=\"middle\" fill=\"#666\">\u5927\u5bb6\u90fd\u77e5\u9053<\/text>\n  <\/g>\n\n  <!-- Step 1: Private Colors -->\n  <g transform=\"translate(50, 150)\">\n    <text x=\"100\" y=\"-20\" font-family=\"Arial\" font-size=\"16\" font-weight=\"bold\" text-anchor=\"middle\" fill=\"#1976D2\">Alice<\/text>\n    \n    <rect x=\"50\" y=\"0\" width=\"100\" height=\"40\" fill=\"#FF5252\" stroke=\"#333\" stroke-width=\"2\"\/>\n    <text x=\"100\" y=\"25\" font-family=\"Arial\" font-size=\"12\" text-anchor=\"middle\" fill=\"white\">\u79c1\u6709\u989c\u8272 (a)<\/text>\n    <text x=\"100\" y=\"55\" font-family=\"Arial\" font-size=\"10\" text-anchor=\"middle\" fill=\"#666\">\u5343\u4e07\u4e0d\u80fd\u7ed9\u522b\u4eba\u770b<\/text>\n  <\/g>\n\n  <g transform=\"translate(550, 150)\">\n    <text x=\"100\" y=\"-20\" font-family=\"Arial\" font-size=\"16\" font-weight=\"bold\" text-anchor=\"middle\" fill=\"#388E3C\">Bob<\/text>\n    \n    <rect x=\"50\" y=\"0\" width=\"100\" height=\"40\" fill=\"#448AFF\" stroke=\"#333\" stroke-width=\"2\"\/>\n    <text x=\"100\" y=\"25\" font-family=\"Arial\" font-size=\"12\" text-anchor=\"middle\" fill=\"white\">\u79c1\u6709\u989c\u8272 (b)<\/text>\n    <text x=\"100\" y=\"55\" font-family=\"Arial\" font-size=\"10\" text-anchor=\"middle\" fill=\"#666\">\u5343\u4e07\u4e0d\u80fd\u7ed9\u522b\u4eba\u770b<\/text>\n  <\/g>\n\n  <!-- Step 2: Mixing (Public Keys) -->\n  <g transform=\"translate(50, 250)\">\n    <rect x=\"50\" y=\"0\" width=\"100\" height=\"40\" fill=\"#FFCC80\" stroke=\"#333\" stroke-width=\"2\"\/>\n    <text x=\"100\" y=\"25\" font-family=\"Arial\" font-size=\"12\" text-anchor=\"middle\">\u6df7\u5408\u8272 (A)<\/text>\n    <text x=\"100\" y=\"55\" font-family=\"Arial\" font-size=\"10\" text-anchor=\"middle\" fill=\"#666\">\u79c1\u6709\u7ea2 + \u516c\u5171\u9ec4<\/text>\n  <\/g>\n\n  <g transform=\"translate(550, 250)\">\n    <rect x=\"50\" y=\"0\" width=\"100\" height=\"40\" fill=\"#C8E6C9\" stroke=\"#333\" stroke-width=\"2\"\/>\n    <text x=\"100\" y=\"25\" font-family=\"Arial\" font-size=\"12\" text-anchor=\"middle\">\u6df7\u5408\u8272 (B)<\/text>\n    <text x=\"100\" y=\"55\" font-family=\"Arial\" font-size=\"10\" text-anchor=\"middle\" fill=\"#666\">\u79c1\u6709\u84dd + \u516c\u5171\u9ec4<\/text>\n  <\/g>\n\n  <!-- Exchange Arrows -->\n  <g transform=\"translate(300, 270)\">\n    <line x1=\"-50\" y1=\"0\" x2=\"250\" y2=\"0\" stroke=\"#666\" stroke-width=\"2\" marker-end=\"url(#arrow)\"\/>\n    <text x=\"100\" y=\"-10\" font-family=\"Arial\" font-size=\"12\" text-anchor=\"middle\">\u4ea4\u6362\u6df7\u5408\u540e\u7684\u989c\u8272 (\u516c\u94a5)<\/text>\n    <line x1=\"250\" y1=\"20\" x2=\"-50\" y2=\"20\" stroke=\"#666\" stroke-width=\"2\" marker-end=\"url(#arrow)\"\/>\n  <\/g>\n\n  <!-- Step 3: Final Secret -->\n  <g transform=\"translate(50, 350)\">\n    <rect x=\"50\" y=\"0\" width=\"100\" height=\"40\" fill=\"#795548\" stroke=\"#333\" stroke-width=\"2\"\/>\n    <text x=\"100\" y=\"25\" font-family=\"Arial\" font-size=\"12\" text-anchor=\"middle\" fill=\"white\">\u6700\u7ec8\u79d8\u5bc6 (S)<\/text>\n    <text x=\"100\" y=\"55\" font-family=\"Arial\" font-size=\"10\" text-anchor=\"middle\" fill=\"#666\">Bob\u7684\u6df7\u5408\u8272 + Alice\u79c1\u6709\u7ea2<\/text>\n  <\/g>\n\n  <g transform=\"translate(550, 350)\">\n    <rect x=\"50\" y=\"0\" width=\"100\" height=\"40\" fill=\"#795548\" stroke=\"#333\" stroke-width=\"2\"\/>\n    <text x=\"100\" y=\"25\" font-family=\"Arial\" font-size=\"12\" text-anchor=\"middle\" fill=\"white\">\u6700\u7ec8\u79d8\u5bc6 (S)<\/text>\n    <text x=\"100\" y=\"55\" font-family=\"Arial\" font-size=\"10\" text-anchor=\"middle\" fill=\"#666\">Alice\u7684\u6df7\u5408\u8272 + Bob\u79c1\u6709\u84dd<\/text>\n  <\/g>\n\n  <text x=\"400\" y=\"450\" font-family=\"Arial\" font-size=\"14\" font-weight=\"bold\" text-anchor=\"middle\" fill=\"#D84315\">\u7ed3\u679c\uff1a\u4e24\u8fb9\u7684\u6700\u7ec8\u79d8\u5bc6\u989c\u8272\u4e00\u6a21\u4e00\u6837\uff01<\/text>\n\n  <defs>\n    <marker id=\"arrow\" markerWidth=\"10\" markerHeight=\"10\" refX=\"9\" refY=\"3\" orient=\"auto\" markerUnits=\"strokeWidth\">\n      <path d=\"M0,0 L0,6 L9,3 z\" fill=\"#666\" \/>\n    <\/marker>\n  <\/defs>\n<\/svg>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>2.\u6574\u4f53\u6d41\u7a0b\u56fe\u89e3<\/strong><\/h2>\n\n\n\n<p>\u76ee\u524d\u6211\u505a\u7684\u4e91\u63a7\u7cfb\u7edf\u6838\u5fc3\u5b89\u5168\u8bbe\u8ba1\u7406\u5ff5\u662f <strong>\u201c\u4e00\u673a\u4e00\u5bc6\u201d<\/strong> \u4e0e <strong>\u52a8\u6001\u534f\u5546<\/strong>\u3002\u6700\u5f00\u59cb\u4f7f\u7528\u7684\u56fa\u5b9a\u5bc6\u94a5\u52a0\u5bc6\uff0c\u4f46\u4e00\u65e6\u5bc6\u94a5\u6cc4\u9732\uff0c\u5c31\u4f1a\u9020\u6210\u4e00\u7cfb\u5217\u7684\u5b89\u5168\u95ee\u9898\u3002<\/p>\n\n\n\n<p>\u6211\u4eec\u53ef\u4ee5\u628a\u6574\u4e2a\u8fc7\u7a0b\u5206\u4e3a\u4e24\u4e2a\u9636\u6bb5\uff1a<strong>\u63e1\u624b\uff08\u534f\u5546\u94a5\u5319<\/strong>\uff09\u548c <strong>\u901a\u4fe1\uff08\u52a0\u5bc6\u4f20\u8f93\uff09<\/strong>\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>mermaid\n\nsequenceDiagram\n\n\u00a0 \u00a0 participant \u5ba2\u6237\u7aef as C\u8bed\u8a00\u5ba2\u6237\u7aef\n\n\u00a0 \u00a0 participant \u670d\u52a1\u7aef as PHP\u670d\u52a1\u7aef\n\n\u00a0 \u00a0 Note over \u5ba2\u6237\u7aef,\u670d\u52a1\u7aef: === \u7b2c\u4e00\u9636\u6bb5\uff1a\u63e1\u624b (\u534f\u5546\u94a5\u5319) ===\n\n\u00a0 \u00a0 \u5ba2\u6237\u7aef->>\u5ba2\u6237\u7aef: 1. \u751f\u6210\u4e34\u65f6\u516c\u94a5(\u5ba2\u6237\u7aef\u516c\u94a5)\u548c\u79c1\u94a5\n\n\u00a0 \u00a0 \u5ba2\u6237\u7aef->>\u670d\u52a1\u7aef: 2. \u53d1\u9001 \u5ba2\u6237\u7aef\u516c\u94a5 + \u8bbe\u5907ID\n\n\u00a0 \u00a0 \u670d\u52a1\u7aef->>\u670d\u52a1\u7aef: 3. \u751f\u6210\u4e34\u65f6\u516c\u94a5(\u670d\u52a1\u7aef\u516c\u94a5)\u548c\u79c1\u94a5\n\n\u00a0 \u00a0 \u670d\u52a1\u7aef->>\u670d\u52a1\u7aef: 4. \u8ba1\u7b97\u5171\u4eab\u79d8\u5bc6 = \u6df7\u5408(\u670d\u52a1\u7aef\u79c1\u94a5 + \u5ba2\u6237\u7aef\u516c\u94a5)\n\n\u00a0 \u00a0 \u670d\u52a1\u7aef->>\u670d\u52a1\u7aef: 5. \u751f\u6210\u4f1a\u8bdd\u5bc6\u94a5 = \u54c8\u5e0c(\u5171\u4eab\u79d8\u5bc6)\n\n\u00a0 \u00a0 \u670d\u52a1\u7aef->>\u5ba2\u6237\u7aef: 6. \u8fd4\u56de \u670d\u52a1\u7aef\u516c\u94a5\n\n\u00a0 \u00a0 \u5ba2\u6237\u7aef->>\u5ba2\u6237\u7aef: 7. \u8ba1\u7b97\u5171\u4eab\u79d8\u5bc6 = \u6df7\u5408(\u5ba2\u6237\u7aef\u79c1\u94a5 + \u670d\u52a1\u7aef\u516c\u94a5)\n\n\u00a0 \u00a0 \u5ba2\u6237\u7aef->>\u5ba2\u6237\u7aef: 8. \u751f\u6210\u4f1a\u8bdd\u5bc6\u94a5 = \u54c8\u5e0c(\u5171\u4eab\u79d8\u5bc6)\n\n\u00a0 \u00a0 Note right of \u5ba2\u6237\u7aef: \u6b64\u65f6\u53cc\u65b9\u90fd\u62e5\u6709\u4e86\u76f8\u540c\u7684\u4f1a\u8bdd\u5bc6\u94a5\\n\u7f51\u7edc\u4e0a\u53ea\u4f20\u8f93\u4e86\u516c\u94a5\uff0c\u7edd\u5bf9\u6ca1\u4f20\u79c1\u94a5\uff01\n\n\u00a0 \u00a0 Note over \u5ba2\u6237\u7aef,\u670d\u52a1\u7aef: === \u7b2c\u4e8c\u9636\u6bb5\uff1a\u52a0\u5bc6\u901a\u4fe1 (AES) ===\n\n\u00a0 \u00a0 \u5ba2\u6237\u7aef->>\u5ba2\u6237\u7aef: 9. \u539f\u59cb\u6570\u636e -> \u538b\u7f29 -> AES\u52a0\u5bc6(\u7528\u4f1a\u8bdd\u5bc6\u94a5)\n\n\u00a0 \u00a0 \u5ba2\u6237\u7aef->>\u670d\u52a1\u7aef: 10. \u53d1\u9001\u5bc6\u6587\n\n\u00a0 \u00a0 \u670d\u52a1\u7aef->>\u670d\u52a1\u7aef: 11. AES\u89e3\u5bc6(\u7528\u4f1a\u8bdd\u5bc6\u94a5) -> \u89e3\u538b -> \u539f\u59cb\u6570\u636e\n\n\u00a0 \u00a0 \u670d\u52a1\u7aef->>\u5ba2\u6237\u7aef: 12. \u54cd\u5e94\u5bc6\u6587<\/code><\/pre>\n\n\n\n<p><\/p>\n\n\n\n<svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" viewBox=\"0 0 800 1000\">\n  <rect width=\"800\" height=\"1000\" fill=\"#ffffff\" \/>\n  \n  <!-- Title -->\n  <text x=\"400\" y=\"40\" font-family=\"Arial, sans-serif\" font-size=\"24\" text-anchor=\"middle\" font-weight=\"bold\" fill=\"#333\">\u5b89\u5168\u901a\u4fe1\u5168\u6d41\u7a0b\u56fe\u89e3 (ECDH + AES)<\/text>\n\n  <!-- Lifelines -->\n  <line x1=\"200\" y1=\"80\" x2=\"200\" y2=\"950\" stroke=\"#999\" stroke-width=\"2\" stroke-dasharray=\"5,5\"\/>\n  <line x1=\"600\" y1=\"80\" x2=\"600\" y2=\"950\" stroke=\"#999\" stroke-width=\"2\" stroke-dasharray=\"5,5\"\/>\n\n  <!-- Participants -->\n  <rect x=\"100\" y=\"80\" width=\"200\" height=\"50\" fill=\"#e3f2fd\" stroke=\"#2196f3\" rx=\"5\"\/>\n  <text x=\"200\" y=\"110\" font-family=\"Arial\" font-size=\"16\" text-anchor=\"middle\" font-weight=\"bold\">C\u8bed\u8a00\u5ba2\u6237\u7aef<\/text>\n\n  <rect x=\"500\" y=\"80\" width=\"200\" height=\"50\" fill=\"#e8f5e9\" stroke=\"#4caf50\" rx=\"5\"\/>\n  <text x=\"600\" y=\"110\" font-family=\"Arial\" font-size=\"16\" text-anchor=\"middle\" font-weight=\"bold\">PHP\u670d\u52a1\u7aef<\/text>\n\n  <!-- Phase 1: Handshake -->\n  <rect x=\"50\" y=\"160\" width=\"700\" height=\"420\" fill=\"#fff3e0\" fill-opacity=\"0.3\" stroke=\"#ff9800\" stroke-dasharray=\"5,5\" rx=\"10\"\/>\n  <text x=\"80\" y=\"190\" font-family=\"Arial\" font-size=\"14\" font-weight=\"bold\" fill=\"#f57c00\">\u7b2c\u4e00\u9636\u6bb5\uff1a\u63e1\u624b (\u534f\u5546\u94a5\u5319)<\/text>\n\n  <!-- Step 1: Client Init -->\n  <rect x=\"120\" y=\"210\" width=\"160\" height=\"40\" fill=\"#fff\" stroke=\"#666\" rx=\"3\"\/>\n  <text x=\"200\" y=\"235\" font-family=\"Arial\" font-size=\"12\" text-anchor=\"middle\">1. \u751f\u6210\u4e34\u65f6\u516c\u94a5(\u5ba2\u6237\u7aef\u516c\u94a5)\u548c\u79c1\u94a5<\/text>\n\n  <!-- Step 2: Send Pub_C -->\n  <line x1=\"200\" y1=\"280\" x2=\"600\" y2=\"280\" stroke=\"#333\" stroke-width=\"2\" marker-end=\"url(#arrow)\"\/>\n  <text x=\"400\" y=\"270\" font-family=\"Arial\" font-size=\"12\" text-anchor=\"middle\">2. \u53d1\u9001 \u5ba2\u6237\u7aef\u516c\u94a5 + \u8bbe\u5907ID<\/text>\n\n  <!-- Step 3-5: Server Process -->\n  <rect x=\"520\" y=\"310\" width=\"160\" height=\"80\" fill=\"#fff\" stroke=\"#666\" rx=\"3\"\/>\n  <text x=\"600\" y=\"330\" font-family=\"Arial\" font-size=\"12\" text-anchor=\"middle\">3. \u751f\u6210\u4e34\u65f6\u516c\u94a5(\u670d\u52a1\u7aef\u516c\u94a5)\u548c\u79c1\u94a5<\/text>\n  <text x=\"600\" y=\"350\" font-family=\"Arial\" font-size=\"12\" text-anchor=\"middle\">4. \u8ba1\u7b97\u5171\u4eab\u79d8\u5bc6 = \u6df7\u5408(\u670d\u52a1\u7aef\u79c1\u94a5 + \u5ba2\u6237\u7aef\u516c\u94a5)<\/text>\n  <text x=\"600\" y=\"370\" font-family=\"Arial\" font-size=\"12\" text-anchor=\"middle\">5. \u751f\u6210\u4f1a\u8bdd\u5bc6\u94a5 = \u54c8\u5e0c(\u5171\u4eab\u79d8\u5bc6)<\/text>\n\n  <!-- Step 6: Return Pub_S -->\n  <line x1=\"600\" y1=\"420\" x2=\"200\" y2=\"420\" stroke=\"#333\" stroke-width=\"2\" marker-end=\"url(#arrow)\"\/>\n  <text x=\"400\" y=\"410\" font-family=\"Arial\" font-size=\"12\" text-anchor=\"middle\">6. \u8fd4\u56de \u670d\u52a1\u7aef\u516c\u94a5<\/text>\n\n  <!-- Step 7-8: Client Finalize -->\n  <rect x=\"120\" y=\"450\" width=\"160\" height=\"60\" fill=\"#fff\" stroke=\"#666\" rx=\"3\"\/>\n  <text x=\"200\" y=\"475\" font-family=\"Arial\" font-size=\"12\" text-anchor=\"middle\">7. \u8ba1\u7b97\u5171\u4eab\u79d8\u5bc6 = \u6df7\u5408(\u5ba2\u6237\u7aef\u79c1\u94a5 + \u670d\u52a1\u7aef\u516c\u94a5)<\/text>\n  <text x=\"200\" y=\"495\" font-family=\"Arial\" font-size=\"12\" text-anchor=\"middle\">8. \u751f\u6210\u4f1a\u8bdd\u5bc6\u94a5 = \u54c8\u5e0c(\u5171\u4eab\u79d8\u5bc6)<\/text>\n  \n  <text x=\"400\" y=\"550\" font-family=\"Arial\" font-size=\"14\" font-weight=\"bold\" fill=\"#d32f2f\" text-anchor=\"middle\">\u6b64\u65f6\u53cc\u65b9\u62e5\u6709\u76f8\u540c\u7684\u4f1a\u8bdd\u5bc6\u94a5 (\u672a\u5728\u7f51\u7edc\u4f20\u8f93)<\/text>\n\n  <!-- Phase 2: Encrypted Communication -->\n  <rect x=\"50\" y=\"600\" width=\"700\" height=\"320\" fill=\"#e1f5fe\" fill-opacity=\"0.3\" stroke=\"#03a9f4\" stroke-dasharray=\"5,5\" rx=\"10\"\/>\n  <text x=\"80\" y=\"630\" font-family=\"Arial\" font-size=\"14\" font-weight=\"bold\" fill=\"#0288d1\">\u7b2c\u4e8c\u9636\u6bb5\uff1a\u52a0\u5bc6\u901a\u4fe1 (AES)<\/text>\n\n  <!-- Step 9: Client Encrypt -->\n  <rect x=\"120\" y=\"650\" width=\"160\" height=\"40\" fill=\"#fff\" stroke=\"#666\" rx=\"3\"\/>\n  <text x=\"200\" y=\"675\" font-family=\"Arial\" font-size=\"12\" text-anchor=\"middle\">9. \u539f\u59cb\u6570\u636e -> \u538b\u7f29 -> AES\u52a0\u5bc6(\u7528\u4f1a\u8bdd\u5bc6\u94a5)<\/text>\n\n  <!-- Step 10: Send Ciphertext -->\n  <line x1=\"200\" y1=\"720\" x2=\"600\" y2=\"720\" stroke=\"#333\" stroke-width=\"2\" marker-end=\"url(#arrow)\"\/>\n  <text x=\"400\" y=\"710\" font-family=\"Arial\" font-size=\"12\" text-anchor=\"middle\">10. \u53d1\u9001\u5bc6\u6587<\/text>\n\n  <!-- Step 11: Server Decrypt -->\n  <rect x=\"520\" y=\"740\" width=\"160\" height=\"40\" fill=\"#fff\" stroke=\"#666\" rx=\"3\"\/>\n  <text x=\"600\" y=\"765\" font-family=\"Arial\" font-size=\"12\" text-anchor=\"middle\">11. AES\u89e3\u5bc6(\u7528\u4f1a\u8bdd\u5bc6\u94a5) -> \u89e3\u538b -> \u539f\u59cb\u6570\u636e<\/text>\n\n  <!-- Step 12: Response -->\n  <line x1=\"600\" y1=\"810\" x2=\"200\" y2=\"810\" stroke=\"#333\" stroke-width=\"2\" stroke-dasharray=\"5,5\" marker-end=\"url(#arrow)\"\/>\n  <text x=\"400\" y=\"800\" font-family=\"Arial\" font-size=\"12\" text-anchor=\"middle\">12. \u54cd\u5e94\u5bc6\u6587<\/text>\n\n  <!-- Definitions -->\n  <defs>\n    <marker id=\"arrow\" markerWidth=\"10\" markerHeight=\"10\" refX=\"9\" refY=\"3\" orient=\"auto\" markerUnits=\"strokeWidth\">\n      <path d=\"M0,0 L0,6 L9,3 z\" fill=\"#333\" \/>\n    <\/marker>\n  <\/defs>\n<\/svg>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>3. \u5b9e\u6218\u5b9e\u73b0\u6b65\u9aa4<\/strong><\/h2>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>\u7b2c\u4e00\u6b65\uff1a\u63e1\u624b (Handshake)<\/strong><\/h3>\n\n\n\n<p>\u5ba2\u6237\u7aef\u548c\u670d\u52a1\u7aef\u5404\u81ea\u751f\u6210\u4e00\u5bf9\u201c\u4e34\u65f6\u8eab\u4efd\u8bc1\u201d\uff08\u692d\u5706\u66f2\u7ebf\u5bc6\u94a5\u5bf9\uff09\u3002<\/p>\n\n\n\n<p><strong>C \u5ba2\u6237\u7aef (OpenSSL)<\/strong><\/p>\n\n\n\n<p>\u5ba2\u6237\u7aef\u751f\u6210\u81ea\u5df1\u7684\u516c\u94a5\uff0c\u5e76\u53d1\u7ed9\u670d\u52a1\u7aef\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/ 1. \u9009\u62e9\u692d\u5706\u66f2\u7ebf (\u5982 prime256v1)\n\nEC_KEY *client_key = EC_KEY_new_by_curve_name(NID_X9_62_prime256v1);\n\nEC_KEY_generate_key(client_key);\n\n\/\/ 2. \u5bfc\u51fa\u516c\u94a5 (Pub_C) \u53d1\u9001\u7ed9\u670d\u52a1\u5668\n\n\/\/ \u8fd9\u4e00\u6b65\u5c31\u50cf\u662f\u628a\u81ea\u5df1\u7684\u201c\u7a7a\u7bb1\u5b50\u201d\u53d1\u7ed9\u5bf9\u65b9\n\nchar *pub_pem = get_public_key_pem(client_key);\n\nhttp_post(\"\/api\/handshake\", pub_pem);<\/code><\/pre>\n\n\n\n<p><\/p>\n\n\n\n<p><strong>PHP \u670d\u52a1\u7aef<\/strong><\/p>\n\n\n\n<p>\u670d\u52a1\u7aef\u6536\u5230\u5ba2\u6237\u7aef\u516c\u94a5\u540e\uff0c\u7ed3\u5408\u81ea\u5df1\u7684\u79c1\u94a5\u7b97\u51fa\u79d8\u5bc6\uff0c\u5e76\u628a\u81ea\u5df1\u7684\u516c\u94a5\u56de\u4f20\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/ \u6536\u5230\u5ba2\u6237\u7aef\u516c\u94a5 $client_pub\n\n\/\/ 1. \u751f\u6210\u670d\u52a1\u7aef\u5bc6\u94a5\u5bf9\n\n$server_key = openssl_pkey_new(&#91;\"digest_alg\" => \"sha256\", ...]);\n\n\/\/ 2. \u8ba1\u7b97\u5171\u4eab\u79d8\u5bc6\n\n\/\/ \u53ea\u6709\u6211\u77e5\u9053\u6211\u7684\u79c1\u94a5\uff0c\u7ed3\u5408\u4f60\u7684\u516c\u94a5\uff0c\u6211\u5c31\u80fd\u7b97\u51fa\u79d8\u5bc6\n\n$shared_secret = openssl_dh_compute_key($client_pub, $server_key);\n\n\/\/ 3. \u5c06\u79d8\u5bc6\u5904\u7406\u6210\u56fa\u5b9a\u957f\u5ea6\u7684 AES \u5bc6\u94a5 (Session Key)\n\n$session_key = substr(hash('sha256', $shared_secret), 0, 32);\n\n\/\/ 4. \u628a\u670d\u52a1\u7aef\u7684\u516c\u94a5\u8fd4\u56de\u7ed9\u5ba2\u6237\u7aef\n\nreturn $server_pub;<\/code><\/pre>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>\u7b2c\u4e8c\u6b65\uff1a\u751f\u6210\u4f1a\u8bdd\u5bc6\u94a5 (Key Derivation)<\/strong><\/h3>\n\n\n\n<p>\u5f53\u5ba2\u6237\u7aef\u6536\u5230\u670d\u52a1\u7aef\u7684\u516c\u94a5\u540e\uff0c\u4e5f\u4f1a\u8fdb\u884c\u540c\u6837\u7684\u8ba1\u7b97\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/ C \u8bed\u8a00\u7aef\n\n\/\/ \u4f7f\u7528 \u81ea\u5df1\u7684\u79c1\u94a5 + \u670d\u52a1\u7aef\u7684\u516c\u94a5 = \u540c\u6837\u7684\u5171\u4eab\u79d8\u5bc6\n\nint secret_len = ECDH_compute_key(shared_secret, server_pub_point, client_key, ...);\n\n\/\/ \u540c\u6837\u8fdb\u884c\u54c8\u5e0c\u5904\u7406\uff0c\u5f97\u5230 Session Key\n\nsha256(shared_secret, session_key);<\/code><\/pre>\n\n\n\n<p><\/p>\n\n\n\n<p><strong>\u7ed3\u679c<\/strong>\uff1a\u73b0\u5728\uff0c\u5ba2\u6237\u7aef\u548c\u670d\u52a1\u7aef\u624b\u91cc\u90fd\u6709\u4e86<strong>**\u4e00\u6a21\u4e00\u6837**<\/strong>\u7684 `session_key`\uff0c\u800c\u8fd9\u4e2a Key \u4ece\u6765\u6ca1\u6709\u5728\u7f51\u7edc\u4e0a\u4f20\u8f93\u8fc7\uff01<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>\u7b2c\u4e09\u6b65\uff1a\u52a0\u5bc6\u901a\u4fe1 (AES Encryption)<\/strong><\/h3>\n\n\n\n<p>\u6709\u4e86\u94a5\u5319\uff0c\u63a5\u4e0b\u6765\u7684\u901a\u4fe1\u5c31\u7b80\u5355\u4e86\u3002\u4e3a\u4e86\u66f4\u5b89\u5168\u548c\u9ad8\u6548\uff0c\u901a\u5e38\u9075\u5faa\u4ee5\u4e0b\u6b65\u9aa4\uff1a<\/p>\n\n\n\n<p>1. \u00a0<strong>\u538b\u7f29 (Compress)<\/strong>\uff1a\u660e\u6587\u6570\u636e\uff08JSON\uff09\u5148\u538b\u7f29\uff08Gzip\/Zlib\uff09\uff0c\u51cf\u5c0f\u4f53\u79ef\uff0c\u4e5f\u589e\u52a0\u7834\u89e3\u96be\u5ea6\u3002<\/p>\n\n\n\n<p>2. \u00a0<strong>\u52a0\u5bc6 (Encrypt)<\/strong>\uff1a\u4f7f\u7528 `AES-256-CBC` \u7b97\u6cd5\u3002<\/p>\n\n\n\n<p>\u00a0 \u00a0 <strong>IV (\u521d\u59cb\u5316\u5411\u91cf)<\/strong>\uff1a\u901a\u5e38\u53d6 Key \u7684\u524d16\u4f4d\uff0c\u6216\u8005\u968f\u673a\u751f\u6210\u968f\u5bc6\u6587\u4e00\u8d77\u53d1\u9001\u3002<\/p>\n\n\n\n<p>3. \u00a0<strong>\u7f16\u7801 (Encode)<\/strong>\uff1a\u52a0\u5bc6\u540e\u7684\u4e8c\u8fdb\u5236\u4e71\u7801\u8f6c\u4e3a Base64 \u5b57\u7b26\u4e32\uff0c\u9632\u6b62\u4f20\u8f93\u4e71\u7801\u3002<\/p>\n\n\n\n<p><strong>\u6570\u636e\u5305\u793a\u4f8b<\/strong>\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\n{\n\n\u00a0 \u00a0 \"device_id\": \"dev_001\",\n\n\u00a0 \u00a0 \"payload\": \"U2FsdGVkX1+...\" \u00a0\/\/ \u8fd9\u5c31\u662f\u52a0\u5bc6\u540e\u7684\u4e00\u4e32\u4e71\u7801\n\n}\n<\/code><\/pre>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">4. \u603b\u7ed3<\/h2>\n\n\n\n<p><br><br>\u901a\u8fc7 <strong>ECDH \u534f\u5546\u5bc6\u94a5<\/strong> + <strong>AES \u52a0\u5bc6\u6570\u636e<\/strong>\uff0c\u6211\u4eec\u6784\u5efa\u4e86\u4e00\u6761\u5b89\u5168\u7684\u9690\u5f62\u96a7\u9053\u3002<br>*   C \u8bed\u8a00\u5ba2\u6237\u7aef\u8d1f\u8d23\u91c7\u96c6\u6570\u636e\uff0c\u5e95\u5c42\u9ad8\u6548\u6267\u884c\u52a0\u5bc6\u3002<br>*   PHP \u670d\u52a1\u7aef\u8d1f\u8d23\u89e3\u5bc6\u6570\u636e\uff0c\u5904\u7406\u4e1a\u52a1\u903b\u8f91\u3002<br><br>\u8fd9\u5957\u65b9\u6848\u662f\u76ee\u524d\u5de5\u4e1a\u754c\u975e\u5e38\u6210\u719f\u4e14\u6807\u51c6\u7684\u505a\u6cd5\uff0c\u5e7f\u6cdb\u5e94\u7528\u4e8e\u5373\u65f6\u901a\u8baf\uff08\u5982 Telegram, WhatsApp \u7684\u5e95\u5c42\u534f\u8bae\uff09\u3001IoT \u8bbe\u5907\u63a7\u5236\u548c\u91d1\u878d\u6570\u636e\u4f20\u8f93\u4e2d\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5728\u5f53\u4eca\u7684\u7f51\u7edc\u901a\u4fe1\u4e2d\uff0c\u6570\u636e\u7684\u5b89\u5168\u6027\u81f3\u5173\u91cd\u8981\u3002\u672c\u6587\u5c06\u6df1\u5165\u63a2\u8ba8\u4e00\u4e2a\u57fa\u4e8e C \u8bed\u8a00\u5ba2\u6237\u7aef\uff08\u8bbe\u5907\u7aef\uff09\u4e0e PHP \u540e\u7aef\u67b6\u6784 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[5,4],"class_list":["post-48","post","type-post","status-publish","format-standard","hentry","category-learn","tag-c","tag-php"],"_links":{"self":[{"href":"https:\/\/nangao.site\/index.php\/wp-json\/wp\/v2\/posts\/48","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/nangao.site\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/nangao.site\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/nangao.site\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/nangao.site\/index.php\/wp-json\/wp\/v2\/comments?post=48"}],"version-history":[{"count":19,"href":"https:\/\/nangao.site\/index.php\/wp-json\/wp\/v2\/posts\/48\/revisions"}],"predecessor-version":[{"id":68,"href":"https:\/\/nangao.site\/index.php\/wp-json\/wp\/v2\/posts\/48\/revisions\/68"}],"wp:attachment":[{"href":"https:\/\/nangao.site\/index.php\/wp-json\/wp\/v2\/media?parent=48"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/nangao.site\/index.php\/wp-json\/wp\/v2\/categories?post=48"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/nangao.site\/index.php\/wp-json\/wp\/v2\/tags?post=48"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}