{"id":282,"date":"2021-08-23T12:10:10","date_gmt":"2021-08-23T04:10:10","guid":{"rendered":"http:\/\/blog.nonot.cn\/?p=282"},"modified":"2023-09-28T23:16:05","modified_gmt":"2023-09-28T15:16:05","slug":"%e4%b8%80%e6%96%87%e8%af%bb%e6%87%82%e5%93%88%e5%b8%8c%e5%92%8c%e4%b8%80%e8%87%b4%e6%80%a7%e5%93%88%e5%b8%8c%e7%ae%97%e6%b3%95","status":"publish","type":"post","link":"https:\/\/blog.nonot.cn\/index.php\/2021\/08\/23\/%e4%b8%80%e6%96%87%e8%af%bb%e6%87%82%e5%93%88%e5%b8%8c%e5%92%8c%e4%b8%80%e8%87%b4%e6%80%a7%e5%93%88%e5%b8%8c%e7%ae%97%e6%b3%95\/","title":{"rendered":"\u4e00\u6587\u8bfb\u61c2\u54c8\u5e0c\u548c\u4e00\u81f4\u6027\u54c8\u5e0c\u7b97\u6cd5"},"content":{"rendered":"<p><img decoding=\"async\" class=\"medium-zoom-image\" src=\"\/wp-content\/uploads\/replace\/2c6960d012e403eb0f67b93b06a943a1.png\" alt=\"\" \/><\/p>\n<h2 id=\"\u54c8\u5e0c-hash-\u7b97\u6cd5\u4ecb\u7ecd\">\u54c8\u5e0c Hash \u7b97\u6cd5\u4ecb\u7ecd<\/h2>\n<p>\u54c8\u5e0c\u7b97\u6cd5\u4e5f\u53eb\u6563\u5217\u7b97\u6cd5, \u4e0d\u8fc7\u82f1\u6587\u5355\u8bcd\u90fd\u662f Hash, \u7b80\u5355\u4e00\u53e5\u8bdd\u6982\u62ec, \u5c31\u662f\u53ef\u4ee5\u628a\u4efb\u610f\u957f\u5ea6\u7684\u8f93\u5165\u4fe1\u606f\u901a\u8fc7\u7b97\u6cd5\u53d8\u6362\u6210\u56fa\u5b9a\u957f\u5ea6\u7684\u8f93\u51fa\u4fe1\u606f, \u8f93\u51fa\u4fe1\u606f\u4e5f\u5c31\u662f\u54c8\u5e0c\u503c, \u901a\u5e38\u54c8\u5e0c\u503c\u7684\u683c\u5f0f\u662f16\u8fdb\u5236\u6216\u8005\u662f10\u8fdb\u5236, \u6bd4\u5982\u4e0b\u9762\u7684\u4f7f\u7528 md5 \u54c8\u5e0c\u7b97\u6cd5\u7684\u793a\u4f8b<\/p>\n<p><span style=\"color: #ff6600;\">md5(<span class=\"hljs-string\">&#8220;123456&#8221;<\/span>) =&gt; <span class=\"hljs-string\">&#8220;e10adc3949ba59abbe56e057f20f883e&#8221;<\/span><\/span><\/p>\n<p>\u4e3b\u8981\u7279\u70b9\uff1a<\/p>\n<ul>\n<li>\u4e0d\u53ef\u9006 \u4ece\u54c8\u5e0c\u503c\u4e0d\u80fd\u63a8\u5bfc\u51fa\u539f\u59cb\u6570\u636e, \u6240\u4ee5Hash\u7b97\u6cd5\u5e7f\u6cdb\u5e94\u7528\u5728\u73b0\u4ee3\u5bc6\u7801\u4f53\u7cfb\u4e2d<\/li>\n<li>\u65e0\u78b0\u649e \u4e0d\u540c\u7684\u4fe1\u606f\u8fdb\u884c\u54c8\u5e0c\u540e\u5f97\u5230\u7684\u503c\u5e94\u8be5\u662f\u4e0d\u540c\u7684, \u4f46\u662f\u4ece\u7406\u8bba\u4e0a\u6765\u8bf4, \u54c8\u5e0c\u7b97\u6cd5\u5176\u5b9e\u662f\u6709\u53ef\u80fd\u53d1\u751f\u78b0\u649e\u7684, \u8f93\u5165\u7684\u4fe1\u606f\u662f\u65e0\u7a77\u7684, \u800c\u8f93\u51fa\u7684\u54c8\u5e0c\u503c\u957f\u5ea6\u662f\u56fa\u5b9a\u7684, \u6240\u4ee5\u662f\u6709\u9650\u7684\u3002\u597d\u6bd4\u8981\u628a10\u4e2a\u82f9\u679c\u653e\u52309\u4e2a\u62bd\u5c49\u91cc\u9762, \u80af\u5b9a\u4f1a\u6709\u4e00\u4e2a\u62bd\u5c49\u88c5\u4e86\u591a\u4e2a\u82f9\u679c, \u53ea\u4e0d\u8fc7\u54c8\u5e0c\u7b97\u6cd5\u7684\u78b0\u649e\u7684\u6982\u7387\u662f\u975e\u5e38\u5c0f\u7684, \u6bd4\u5982128\u4f4d\u7684\u54c8\u5e0c\u503c, \u5c31\u67092\u7684128\u6b21\u65b9\u7684\u7a7a\u95f4\u3002<\/li>\n<li>\u6548\u7387\u9ad8 \u5728\u5904\u7406\u6bd4\u8f83\u5927\u7684\u539f\u751f\u503c\u65f6, \u4e5f\u80fd\u80fd\u5feb\u901f\u7684\u8ba1\u7b97\u51fa\u54c8\u5e0c\u503c<\/li>\n<li>\u65e0\u89c4\u5f8b \u539f\u59cb\u8f93\u5165\u4fe1\u606f\u4fee\u6539\u4e00\u70b9\u4fe1\u606f, \u5f97\u5230\u7684\u54c8\u5e0c\u503c\u4e5f\u662f\u5927\u4e0d\u76f8\u540c\u7684<\/li>\n<\/ul>\n<p>\u54c8\u5e0c\u7b97\u6cd5\u7684\u5b9e\u73b0\u6709\u5f88\u591a, \u5e38\u89c1\u7684\u6709 MD5, SHA-1, \u8fd8\u6709\u50cf C#, Java \u4e00\u4e9b\u8bed\u8a00\u90fd\u6709\u76f4\u63a5\u7684 GetHashCode(), hashCode() \u51fd\u6570\u53ef\u4ee5\u76f4\u63a5\u6765\u7528\u3002<\/p>\n<h2 id=\"\u5206\u5e03\u5f0f\u5b58\u50a8\u573a\u666f\">\u5206\u5e03\u5f0f\u5b58\u50a8\u573a\u666f<\/h2>\n<p>\u5728\u4e92\u8054\u7f51\u573a\u666f\u4e2d, \u901a\u5e38\u9762\u5bf9\u7684\u90fd\u662f\u6d77\u91cf\u7684\u6570\u636e,\u6d77\u91cf\u7684\u7528\u6237, \u90a3\u4e3a\u4e86\u8981\u6ee1\u8db3\u5927\u91cf\u6570\u636e\u7684\u5199\u5165\u548c\u67e5\u8be2, \u4ee5\u53ca\u9ad8\u53ef\u7528, \u4e00\u53f0\u5355\u673a\u7684\u5b58\u50a8\u670d\u52a1\u5668\u80af\u5b9a\u662f\u4e0d\u80fd\u6ee1\u8db3\u9700\u6c42\u7684, \u901a\u5e38\u9700\u8981\u4f7f\u7528\u591a\u53f0\u670d\u52a1\u5668\u5f62\u6210\u5206\u5e03\u5f0f\u5b58\u50a8\u3002<\/p>\n<p><strong>\u573a\u666f\u63cf\u8ff0:<\/strong><\/p>\n<p>\u5728\u672c\u6587\u4e2d, \u4e3a\u4e86\u65b9\u4fbf\u5927\u5bb6\u66f4\u597d\u7684\u7406\u89e3, \u8fd9\u91cc\u5217\u51fa\u4e86\u4e00\u4e2a\u7b80\u5355\u7684\u4f8b\u5b50, \u6709\u4e09\u4f4d\u7528\u6237, \u5206\u522b\u662f James\u3001 Bob\u3001 Lee, \u6211\u4eec\u9700\u8981\u628a\u7528\u6237\u7684\u56fe\u7247\u5199\u5165\u5230\u5b58\u50a8\u670d\u52a1\u5668\u8282\u70b9, \u8fd9\u91cc\u6709ABC\u4e09\u4e2a\u8282\u70b9, \u800c\u4e14\u5f53\u67e5\u8be2\u7528\u6237\u7684\u56fe\u7247\u65f6, \u8fd8\u9700\u8981\u5feb\u901f\u5b9a\u4f4d\u5230\u8fd9\u4e2a\u7528\u6237\u7684\u56fe\u7247\u662f\u5728\u54ea\u4e2a\u8282\u70b9\u5b58\u50a8\u7684, \u7136\u540e\u76f4\u63a5\u4ece\u8fd9\u4e2a\u8282\u70b9\u8fdb\u884c\u67e5\u8be2, \u9700\u8981\u6ee1\u8db3\u9ad8\u6548\u7387\u7684\u67e5\u8be2\u3002<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/blog.nonot.cn\/wp-content\/uploads\/2021\/08\/2bfb0-clipboard_20210813_111129.png\" alt=\"\" \/><\/p>\n<p><strong>\u5b9e\u73b0\u601d\u8def:<\/strong><\/p>\n<p>\u9996\u5148,\u6211\u4eec\u53ef\u4ee5\u5bf9\u7528\u6237\u6807\u8bc6\u8fdb\u884c Hash \u8ba1\u7b97, \u8fd9\u91cc\u6211\u4e3a\u4e86\u65b9\u4fbf\u6f14\u793a, \u4f7f\u7528\u4e86\u7528\u6237\u540d\u4f5c\u4e3aHash\u5bf9\u8c61, \u5f53\u7136\u4f60\u8fd8\u53ef\u4ee5\u5bf9\u7528\u6237\u7684IP\u6216\u8005\u662fUserId \u8fdb\u884cHash\u8ba1\u7b97, Hash\u8ba1\u7b97\u540e\u4f1a\u751f\u6210\u4e00\u4e2aint\u7c7b\u578b\u7684\u6570\u5b57, \u7136\u540e\u518d\u6839\u636e\u5b58\u50a8\u8282\u70b9\u7684\u6570\u91cf\u8fdb\u884c\u53d6\u6a21, \u8fd9\u91cc\u7684\u516c\u5f0f\u5c31\u662f\u00a0<strong>hash(name) % 3<\/strong>, \u8ba1\u7b97\u5f97\u51fa\u7684\u7ed3\u679c\u53ea\u6709\u4e09\u79cd\u60c5\u51b5, \u5206\u522b\u662f 0,1,2, \u7136\u540e\u6211\u4eec\u518d\u628a\u8fd9\u4e09\u79cd\u7ed3\u679c\u548c\u4e09\u4e2a\u5b58\u50a8\u8282\u70b9\u505a\u4e00\u4e2a\u6620\u5c04, 0 ==&gt; A, 1 ==&gt; B, 2 == C\u3002 \u56e0\u4e3aHash\u7b97\u6cd5\u5bf9\u4e00\u4e2a\u503c\u591a\u6b21\u8ba1\u7b97\u540e\u90fd\u4f1a\u5f97\u5230\u540c\u6837\u7684hash\u503c, \u6240\u4ee5\u4e0a\u9762\u7684\u516c\u5f0f, \u4e00\u4e2a\u7528\u6237\u7684\u56fe\u7247\u6bcf\u6b21\u90fd\u4f1a\u56fa\u5b9a\u7684\u5199\u5165\u7684\u5176\u4e2d\u4e00\u4e2a\u8282\u70b9, \u8fd9\u6837\u505a\u67e5\u8be2\u7684\u8bdd, \u4e5f\u53ef\u4ee5\u901a\u8fc7hash\u7b97\u6cd5\u5feb\u901f\u627e\u5230\u8fd9\u4e2a\u7528\u6237\u7684\u56fe\u7247\u6240\u5728\u7684\u8282\u70b9\u3002<\/p>\n<p><img decoding=\"async\" class=\"medium-zoom-image\" src=\"http:\/\/blog.nonot.cn\/wp-content\/uploads\/2021\/08\/d46ee-clipboard_20210810_064350.png\" alt=\"\" \/><\/p>\n<p><strong>\u7f3a\u70b9:<\/strong><\/p>\n<p>\u4e0a\u9762\u6211\u4eec\u4f7f\u7528Hash\u7b97\u6cd5\u5b9e\u73b0\u4e86\u8d1f\u8f7d\u5747\u8861, \u53ef\u4ee5\u6839\u636e\u7528\u6237\u540d\u8def\u7531\u5230\u56fe\u7247\u6240\u5728\u7684\u8282\u70b9, \u4f46\u662f\u4e0a\u9762\u7684\u65b9\u6cd5\u4e5f\u6709\u4e00\u4e2a\u5f88\u5927\u7684\u7f3a\u70b9, \u90a3\u5c31\u662f\u5f53\u670d\u52a1\u5668\u7684\u6570\u91cf\u589e\u52a0\u6216\u8005\u51cf\u5c11\u65f6, \u6211\u4eec\u901a\u8fc7Hash\u7b97\u6cd5\u751f\u6210\u7684\u8def\u7531\u89c4\u5219\u5c31\u518d\u4e0d\u51c6\u786e\u4e86\u3002<\/p>\n<p>\u8bd5\u60f3\u4e00\u4e0b, \u5982\u679c\u65b0\u589e\u6216\u8005\u51cf\u5c11\u4e00\u4e2a\u8282\u70b9, \u4e0a\u9762\u7684\u516c\u5f0f\u5c31\u4f1a\u53d8\u6210\u00a0<strong>hash(name) % 4<\/strong>\u00a0\u6216\u8005\u00a0<strong>hash(name) % 2<\/strong>, \u8fd9\u91cc\u7684\u5173\u952e\u70b9\u662f, \u6211\u4eec\u4e4b\u524d\u75283\u53d6\u6a21, \u73b0\u5728\u53d8\u6210\u75284\u6216\u80052\u53d6\u6a21, \u7ed3\u679c\u5f53\u7136\u5927\u6982\u7387\u662f\u4e0d\u4e00\u6837\u4e86, \u5f53\u7136\u5982\u679c Hash\u540e\u662f12\u7684\u8bdd,\u75283\u6216\u80054\u53d6\u6a21\u5f97\u5230\u7684\u7ed3\u679c\u90fd\u662f\u4e3a0, \u4e0d\u8fc7\u8fd9\u79cd\u6982\u7387\u6bd4\u8f83\u5c0f\u3002<\/p>\n<p>\u8fd9\u4e2a\u95ee\u9898\u5e26\u6765\u7684\u5f71\u54cd\u662f, \u8def\u7531\u89c4\u5219\u4e0d\u518d\u51c6\u786e, \u5927\u90e8\u5206\u7684\u67e5\u8be2\u8bf7\u6c42\u90fd\u6251\u4e86\u7a7a\u3002\u90a3\u4e48\u5982\u4f55\u89e3\u51b3\u8fd9\u4e2a\u95ee\u9898\u5462\uff1f\u76f8\u4fe1\u6709\u7684\u540c\u5b66\u8fd9\u65f6\u5e94\u8be5\u6709\u4e86\u4e00\u4e9b\u60f3\u6cd5, \u662f\u7684\u6ca1\u9519, \u5173\u952e\u70b9\u5c31\u5728\u4e8e, \u4e0d\u7ba1\u8282\u70b9\u7684\u6570\u91cf\u600e\u4e48\u53d8\u5316, \u90fd\u5e94\u8be5\u4f7f\u7528\u4e00\u4e2a\u56fa\u5b9a\u7684\u503c\u6765\u8fdb\u884c\u53d6\u6a21\uff01 \u53ea\u6709\u8fd9\u6837\u624d\u80fd\u4fdd\u8bc1\u6bcf\u6b21\u8fdb\u884cHash\u8ba1\u7b97\u540e, \u5f97\u51fa\u7684\u7ed3\u679c\u662f\u4e0d\u53d8\u7684!<\/p>\n<h2 id=\"\u4e00\u81f4\u6027hash\u7b97\u6cd5\">\u4e00\u81f4\u6027Hash\u7b97\u6cd5<\/h2>\n<p>\u540c\u6837\u7684,\u4e00\u81f4\u6027Hash\u7b97\u6cd5\u4e5f\u662f\u5229\u7528\u53d6\u6a21\u7684\u65b9\u5f0f, \u4e0d\u8fc7\u901a\u5e38\u662f\u7528\u4e00\u4e2a\u5f88\u5927\u7684\u6570\u5b57\u8fdb\u884c\u6c42\u6a21, \u4f60\u53ef\u4ee5\u7528\u6574\u6570\u7684\u6700\u5927\u503c int.Max, 2\u768432\u6b21\u65b9, \u5f53\u7136\u8fd9\u4e2a\u5e76\u6ca1\u6709\u8981\u6c42, \u4e0d\u8fc7\u8d8a\u5927\u7684\u6570\u5b57, \u5e73\u5747\u5206\u914d\u7684\u6982\u7387\u5c31\u8d8a\u5927(\u540e\u9762\u4f1a\u5177\u4f53\u4ecb\u7ecd\u8fd9\u4e2a\u95ee\u9898)\u3002<\/p>\n<p>\u4e3a\u4e86\u65b9\u4fbf\u7406\u89e3, \u8fd9\u91cc\u6211\u7528 1000 \u6765\u53d6\u6a21, \u6211\u4eec\u53ef\u4ee5\u7528\u4e00\u4e2a\u957f\u5ea6\u4e3a1000\u7684\u6570\u7ec4\u8868\u793a\u5b83,\u5c31\u50cf\u8fd9\u6837<\/p>\n<p><img decoding=\"async\" class=\"medium-zoom-image\" src=\"http:\/\/blog.nonot.cn\/wp-content\/uploads\/2021\/08\/2694d-clipboard_20210813_024855.png\" alt=\"\" \/><\/p>\n<p>\u63a5\u4e0b\u6765, \u6211\u4eec\u5148\u4e0d\u5bf9\u7528\u6237\u7684\u56fe\u7247\u8fdb\u884cHash\u5904\u7406, \u800c\u662f\u5148\u5bf9\u6bcf\u4e2a\u8282\u70b9\u8fdb\u884c Hash \u5904\u7406\u548c\u6620\u5c04, \u73b0\u5728\u7684\u516c\u5f0f\u5206\u522b\u662f\u00a0<span style=\"color: #ff6600;\"><code>hash(A) % 1000<\/code><\/span>,\u00a0<span style=\"color: #ff6600;\"><code>hash(B) % 1000<\/code><\/span>,<span style=\"color: #ff6600;\"><code>hash(C) % 1000<\/code><\/span>, \u8fd9\u6837\u5f97\u51fa\u7684\u7ed3\u679c\u4e00\u5b9a\u662f\u57280-999 \u4e4b\u95f4, \u7136\u540e\u628a\u8fd9\u4e2a\u503c\u6620\u5c04\u5230\u6570\u7ec4\u4e2d, \u5728\u4ee3\u7801\u4e2d, \u4f60\u53ef\u4ee5\u7528\u4e00\u4e2a\u5b57\u5178\u96c6\u5408\u6765\u4fdd\u5b58\u8fd9\u4e2a\u6620\u5c04\u5173\u7cfb\u3002<\/p>\n<p>\u5bf9\u5e94\u7684\u5b58\u50a8\u8282\u70b9\u548c\u6570\u7ec4\u7684\u6620\u5c04\u53ef\u80fd\u5982\u4e0b\uff1a<\/p>\n<p><img decoding=\"async\" class=\"medium-zoom-image\" src=\"http:\/\/blog.nonot.cn\/wp-content\/uploads\/2021\/08\/cd196-clipboard_20210813_035449.png\" alt=\"\" \/><\/p>\n<p>\u90a3\u73b0\u5728\u7528\u6237\u7684\u56fe\u7247\u600e\u4e48\u548c\u5b58\u50a8\u8282\u70b9\u5bf9\u5e94\u5462\uff1f \u56e0\u4e3a\u5b58\u50a8\u8282\u70b9\u5df2\u7ecf\u6620\u5c04\u5230\u4e86\u6570\u7ec4\u4e0a, \u6211\u4eec\u73b0\u5728\u53ef\u4ee5\u901a\u8fc7\u8303\u56f4\u533a\u95f4\u7684\u65b9\u5f0f, \u6765\u627e\u5230\u5bf9\u5e94\u7684\u8282\u70b9, \u6620\u5c04\u5728\u6570\u7ec4\u4e0a\u7684\u56fe\u7247\u53ef\u4ee5\u5411\u53f3\u67e5\u627e, \u627e\u5230\u4e86\u4e00\u4e2a\u8282\u70b9, \u90a3\u4e48\u8fd9\u4e2a\u56fe\u7247\u5c31\u5c5e\u4e8e\u8fd9\u4e2a\u8282\u70b9, \u5f53\u5f80\u53f3\u67e5\u627e\u5230\u6700\u5927\u503c\u65f6,\u518d\u56de\u5230\u6700\u5de6\u8fb9\u4ece0\u5f00\u59cb\u3002<\/p>\n<p>\u6211\u5728\u56fe\u4e2d\u7528\u4e0d\u540c\u7684\u989c\u8272\u6807\u8bb0\u4e86\u6bcf\u4e2a\u5b58\u50a8\u670d\u52a1\u5668\u7684\u8303\u56f4\u533a\u95f4, \u4f60\u53ef\u4ee5\u7406\u89e3\u4e00\u4e0b<\/p>\n<p><img decoding=\"async\" class=\"medium-zoom-image\" src=\"http:\/\/blog.nonot.cn\/wp-content\/uploads\/2021\/08\/84e7e-clipboard_20210813_035544.png\" alt=\"\" \/><\/p>\n<p>\u63a5\u4e0b\u6765, \u6211\u4eec\u5c31\u9700\u8981\u5bf9\u7528\u6237\u7684\u56fe\u7247\u8fdb\u884cHash\u8ba1\u7b97\u53d6\u6a21,\u540c\u6837\u7684,\u8ba1\u7b97\u7ed3\u679c\u4e00\u5b9a\u8fd8\u662f\u57280-999\u7684\u8303\u56f4\u5185, \u7136\u540e\u518d\u628a\u8fd9\u4e9b\u503c\u6620\u5c04\u5230\u6570\u7ec4\u4e0a, \u6620\u5c04\u7684\u7ed3\u679c\u53ef\u80fd\u5982\u4e0b\u56fe:<\/p>\n<p><img decoding=\"async\" class=\"medium-zoom-image\" src=\"http:\/\/blog.nonot.cn\/wp-content\/uploads\/2021\/08\/34f7c-clipboard_20210814_102113.png\" alt=\"\" \/><\/p>\n<p>\u8fd9\u6837\u5c31\u53ef\u4ee5\u901a\u8fc7\u5f80\u53f3\u67e5\u627e\u7684\u65b9\u5f0f, \u627e\u5230\u7528\u6237\u7684\u56fe\u7247\u76f8\u5bf9\u5e94\u7684\u5b58\u50a8\u8282\u70b9! \u603b\u7ed3\u4e0b\u6765\u4e0a\u9762\u505a\u4e86\u51e0\u4ef6\u4e8b\u60c5, \u9996\u5148\u6211\u4eec\u53d6\u4e00\u4e2a\u56fa\u5b9a\u7684\u5e76\u4e14\u6bd4\u8f83\u5927\u7684\u6574\u6570\u8fdb\u884c\u6c42\u6a21, \u7136\u540e\u5728\u5bf9\u6bcf\u4e2a\u8282\u70b9\u8fdb\u884cHash\u8ba1\u7b97\u6c42\u6a21, \u8fd9\u6837\u53ef\u4ee5\u627e\u51fa\u6bcf\u4e2a\u8282\u70b9\u6240\u5bf9\u5e94\u7684\u8303\u56f4\u533a\u95f4, \u6700\u540e\u518d\u628a\u7528\u6237\u7684\u56fe\u7247\u8fdb\u884cHash\u8ba1\u7b97\u6c42\u6a21, \u6700\u540e\u6839\u636e\u8303\u56f4\u533a\u95f4\u786e\u5b9a\u56fe\u7247\u7684\u6240\u5728\u7684\u5b58\u50a8\u8282\u70b9\u3002<\/p>\n<p>\u90a3\u6211\u4eec\u770b\u770b\u4f7f\u7528\u4e86\u8fd9\u79cd\u65b9\u5f0f, \u5f53\u5b58\u50a8\u8282\u70b9\u7684\u589e\u52a0\u548c\u51cf\u5c11\u65f6\u4f1a\u6709\u4ec0\u4e48\u5f71\u54cd\uff1f<\/p>\n<p><strong>\u8282\u70b9\u589e\u52a0\u573a\u666f<\/strong><\/p>\n<p><img decoding=\"async\" class=\"medium-zoom-image\" src=\"http:\/\/blog.nonot.cn\/wp-content\/uploads\/2021\/08\/3dd8b-clipboard_20210814_101840.png\" alt=\"\" \/><\/p>\n<p>\u8fd9\u91cc\u6211\u65b0\u589e\u4e86\u4e00\u4e2a\u5b58\u50a8\u8282\u70b9D, \u7ecf\u8fc7Hash\u8ba1\u7b97\u540e\u6620\u5c04\u5728\u6570\u7ec4\u4e0a, \u8fd9\u6837\u7684\u8bdd, \u7528\u6237 James \u672c\u6765\u662f\u8def\u7531\u5230C\u8282\u70b9\u7684,\u73b0\u5728\u88ab\u8def\u7531\u5230\u4e86D\u8282\u70b9, \u4e0d\u8fc7\u6211\u4eec\u6dfb\u52a0\u4e86D\u8282\u70b9\u540e, \u53d7\u5230\u5f71\u54cd\u7684\u4e5f\u53ea\u6709C\u8282\u70b9, \u5176\u5b9e\u4e0d\u7ba1D\u8282\u70b9\u6620\u5c04\u5230\u6570\u7ec4\u54ea\u4e00\u4e2a\u4f4d\u7f6e, \u90fd\u53ea\u4f1a\u6709\u4e00\u4e2a\u8282\u70b9\u4f1a\u53d7\u5230\u5f71\u54cd, \u5176\u4ed6\u7684\u8282\u70b9\u53ef\u4ee5\u6b63\u5e38\u4f7f\u7528\u3002<\/p>\n<p>\u90a3\u4e48\u8fd9\u79cd\u60c5\u51b5\u4e0b, \u5982\u4f55\u505a\u6570\u636e\u8fc1\u79fb? \u6211\u7684\u601d\u8def\u662f, \u6211\u4eec\u9700\u8981\u628aC\u8282\u70b9\u5168\u90e8\u6570\u636e\u91cd\u65b0\u8fdb\u884cHash\u8ba1\u7b97, \u7136\u540e\u6839\u636e\u8ba1\u7b97\u7ed3\u679c, \u4e00\u90e8\u5206\u4f1a\u79fb\u52a8\u5230D\u8282\u70b9, \u4e00\u90e8\u5206\u7ee7\u7eed\u4fdd\u7559\u5728C\u8282\u70b9\u3002<\/p>\n<p><strong>\u8282\u70b9\u51cf\u5c11\u573a\u666f<\/strong><\/p>\n<p><img decoding=\"async\" class=\"medium-zoom-image\" src=\"http:\/\/blog.nonot.cn\/wp-content\/uploads\/2021\/08\/89f09-clipboard_20210814_104138.png\" alt=\"\" \/><\/p>\n<p>\u5047\u5982\u73b0\u5728 A \u8282\u70b9\u5728\u665a\u4e0a20\u70b9\u5b95\u673a\u4e86, \u90a3\u4e48\u672c\u6765\u5e94\u8be5\u8def\u7531\u5230A\u8282\u70b9\u7684\u6570\u636e, \u73b0\u5728\u5c31\u88ab\u8def\u7531\u5230\u4e86\u8282\u70b9C, \u4e5f\u5c31\u662f\u56fe\u4e2d\u7684 Bob\u7684\u6570\u636e, \u4f46\u662f\u8fd9\u79cd\u60c5\u51b5\u4e0b, \u5176\u4ed6\u7684\u8282\u70b9\u662f\u4e0d\u4f1a\u53d7\u5230\u8282\u70b9\u53d8\u52a8\u7684\u5f71\u54cd, \u7b49\u5230\u665a\u4e0a21\u70b9\u65f6, A\u8282\u70b9\u53c8\u6062\u590d\u4e86\u6b63\u5e38\u3002<\/p>\n<p>\u8fd9\u79cd\u60c5\u51b5\u7684\u6570\u636e\u8fc1\u79fb\u7684\u601d\u8def\u662f, \u5f53A\u8282\u70b9\u5b95\u673a\u540e, \u6570\u636e\u9700\u8981\u5168\u90e8\u590d\u5236\u5230C\u8282\u70b9, \u5f53A\u8282\u70b9\u6062\u590d\u6b63\u5e38\u540e, \u518d\u628aC\u8282\u70b920:00\u81f321:00\u7684\u6570\u636e\u91cd\u65b0Hash\u8ba1\u7b97, \u7136\u540e\u6839\u636e\u8ba1\u7b97\u7684\u7ed3\u679c, \u4e00\u90e8\u5206\u4f1a\u79fb\u52a8\u5230A\u8282\u70b9, \u4e00\u90e8\u5206\u7ee7\u7eed\u4fdd\u7559\u5728C\u8282\u70b9\u3002<\/p>\n<p><strong>\u8282\u70b9\u5206\u5e03\u4e0d\u5747\u5300<\/strong><\/p>\n<p>\u56e0\u4e3a\u8282\u70b9\u662f\u968f\u673a\u7684\u6563\u5217\u5206\u5e03\u5728\u6570\u7ec4\u4e0a,\u6240\u4ee5\u6709\u7684\u8282\u70b9\u7684\u8303\u56f4\u6bd4\u8f83\u5927, \u800c\u6709\u7684\u8282\u70b9\u7684\u8303\u56f4\u6bd4\u8f83\u5c0f, \u8fd9\u6837\u6211\u4eec\u7684\u6570\u636e\u5206\u5e03\u5c31\u4e0d\u5747\u5300, \u6709\u7684\u8282\u70b9\u670d\u52a1\u5668\u4f1a\u6709\u6bd4\u8f83\u5927\u7684\u8bf7\u6c42\u538b\u529b\u3002<\/p>\n<p>\u8fd9\u79cd\u60c5\u51b5\u6709\u7684\u540c\u5b66\u53ef\u80fd\u4f1a\u8bf4, \u6211\u53ef\u4ee5\u6839\u636e\u6570\u7ec4\u7684\u957f\u5ea6(1000)\u548c\u8282\u70b9(3)\u7684\u4e2a\u6570, \u6c42\u51fa\u5e73\u5747\u503c, \u7136\u540e\u5c31\u53ef\u4ee5\u5e73\u5747\u7684\u628a\u8282\u70b9\u6563\u5217\u5230\u6570\u7ec4\u4e0a, \u8fd9\u6837\u6bcf\u4e2a\u8282\u70b9\u7684\u8bf7\u6c42\u538b\u529b\u90fd\u662f\u4e00\u6837\u7684, \u8fd9\u79cd\u65b9\u5f0f\u770b\u8d77\u6765\u6ca1\u4ec0\u4e48\u95ee\u9898, \u4f46\u662f\u5f53\u6dfb\u52a0\u8282\u70b9\u6216\u8005\u79fb\u9664\u8282\u70b9\u7684\u65f6\u5019, \u6bcf\u4e2a\u8282\u70b9\u7684\u8986\u76d6\u8303\u56f4\u90fd\u9700\u8981\u91cd\u65b0\u8ba1\u7b97, \u7136\u540e\u4e5f\u9700\u8981\u8fc1\u79fb\u6570\u636e, \u5f71\u54cd\u7684\u8303\u56f4\u8fd8\u662f\u633a\u5927\u7684\u3002<\/p>\n<p><img decoding=\"async\" class=\"medium-zoom-image\" src=\"http:\/\/blog.nonot.cn\/wp-content\/uploads\/2021\/08\/33585-clipboard_20210814_061513.png\" alt=\"\" \/><\/p>\n<h2 id=\"\u865a\u62df\u8282\u70b9\">\u865a\u62df\u8282\u70b9<\/h2>\n<p><img decoding=\"async\" class=\"medium-zoom-image\" src=\"http:\/\/blog.nonot.cn\/wp-content\/uploads\/2021\/08\/98ce4-clipboard_20210814_102027.png\" alt=\"\" \/><\/p>\n<p>\u4e4b\u524d\u6211\u4eec\u7528\u4e86\u4e09\u4e2a\u5b58\u50a8\u8282\u70b9, \u53d1\u73b0\u6709\u5206\u5e03\u4e0d\u5747\u5300\u7684\u60c5\u51b5, \u4e0a\u56fe\u662f\u6211\u505a\u4e86\u4e00\u4e2a\u7b80\u5355\u7684\u6d4b\u8bd5, x \u8f74\u662f\u8282\u70b9\u7684\u6570\u91cf, y \u8f74\u662f\u6807\u51c6\u504f\u5dee, \u6839\u636e\u8fd9\u4e2a\u56fe\u7684\u8d8b\u52bf\u5f97\u51fa\u7684\u7ed3\u8bba\u662f, \u8282\u70b9\u8d8a\u591a\u7684\u65f6\u5019, \u6807\u51c6\u504f\u5dee\u4e5f\u5c31\u8d8a\u5c0f, \u8282\u70b9\u5206\u5e03\u7684\u5c31\u8d8a\u5747\u5300\u3002<\/p>\n<p>\u5b9e\u9645\u4e2d,\u670d\u52a1\u5668\u8282\u70b9\u662f\u6709\u9650\u7684, \u589e\u52a0\u5f88\u591a\u8282\u70b9\u4e5f\u80af\u5b9a\u662f\u4e0d\u73b0\u5b9e\u7684, \u90a3\u4e48\u5c31\u53ef\u4ee5\u5728\u670d\u52a1\u5668\u8282\u70b9\u4e0d\u53d8\u7684\u60c5\u51b5\u4e0b, \u5f15\u5165\u865a\u62df\u8282\u70b9, \u4e5f\u53eb\u505a\u5f71\u5b50\u8282\u70b9\u3002<\/p>\n<p><img decoding=\"async\" class=\"medium-zoom-image\" src=\"http:\/\/blog.nonot.cn\/wp-content\/uploads\/2021\/08\/59525-clipboard_20210815_053910.png\" alt=\"\" \/><\/p>\n<p>\u8fd8\u8bb0\u5f97\u6211\u4eec\u4e4b\u524d\u662f\u600e\u4e48\u5bf9\u8282\u70b9\u505ahash\u6620\u5c04\u7684\u5417?\u516c\u5f0f\u662f hash(node) \/ 1000, \u6211\u4eec\u73b0\u5728\u53ef\u4ee5\u7ed9A\u8282\u70b9\u521b\u5efa10\u4e2a\u865a\u62df\u8282\u70b9, \u5206\u522b\u662f A1, A2,A3&#8230;, A10, \u5bf9\u5e94\u7684\u865a\u62df\u8282\u70b9\u7684\u516c\u5f0f\u5c31\u662f hash(A1) \/ 1000 \u7b49\u7b49\u3002\u8fd9\u4e9b\u865a\u62df\u8282\u70b9\u548c\u771f\u5b9e\u8282\u70b9\u5b58\u5728\u6620\u5c04\u5173\u7cfb, \u5f53\u56fe\u7247\u6620\u5c04\u5230A\u8282\u70b9\u7684\u4efb\u610f\u4e00\u4e2a\u865a\u62df\u8282\u70b9\u4e0a\u65f6, \u6211\u4eec\u5c31\u628a\u8fd9\u4e2a\u56fe\u7247\u8def\u7531\u5230A\u5b58\u50a8\u8282\u70b9, \u73b0\u5728\u6570\u7ec4\u4e0a\u5df2\u7ecf\u6709\u4e8630\u4e2a\u865a\u62df\u8282\u70b9\u505a\u6620\u5c04, \u5206\u5e03\u4e5f\u6bd4\u4e4b\u524d\u66f4\u5747\u5300\u4e86, \u5f53\u7136\u4f60\u4e5f\u53ef\u4ee5\u521b\u5efa\u66f4\u591a\u7684\u865a\u62df\u8282\u70b9, \u8fd9\u4e9b\u771f\u5b9e\u8282\u70b9\u548c\u865a\u62df\u8282\u70b9\u7684\u6620\u5c04\u5173\u7cfb\u8981\u4fdd\u5b58\u5728\u5185\u5b58\u4e2d\u6216\u8005\u662f\u6570\u636e\u5e93\u4e2d, \u73b0\u5728\u6211\u4eec\u7684\u6620\u5c04\u56fe\u5982\u4e0b, \u8fd9\u91cc\u6211\u7ed9\u6bcf\u4e2a\u771f\u5b9e\u8282\u70b9\u90fd\u6dfb\u52a0\u4e863\u4e2a\u865a\u62df\u8282\u70b9\u3002<\/p>\n<p><img decoding=\"async\" class=\"medium-zoom-image\" src=\"http:\/\/blog.nonot.cn\/wp-content\/uploads\/2021\/08\/26535-clipboard_20210814_111828.png\" alt=\"\" \/><\/p>\n<p>\u5f15\u5165\u4e86\u865a\u62df\u8282\u70b9\u540e, \u5728\u6570\u7ec4\u7684\u6620\u5c04\u770b\u8d77\u6765\u5e73\u5747\u5f88\u591a\u4e86, \u73b0\u5728\u6211\u4eec\u6bcf\u4e2a\u771f\u5b9e\u8282\u70b9\u7684\u8bf7\u6c42\u538b\u529b\u90fd\u662f\u4e00\u6837\u7684\u4e86, \u63a5\u4e0b\u6765, \u6211\u4eec\u8fd8\u8981\u770b\u4e0b\u8fd9\u4e2a\u65b9\u6848\u5728\u8282\u70b9\u7684\u53d8\u52a8\u60c5\u51b5\u4e0b\u5e94\u8be5\u600e\u4e48\u5904\u7406\u3002<\/p>\n<p><strong>\u589e\u52a0\u8282\u70b9<\/strong><\/p>\n<p>\u73b0\u5728\u589e\u52a0\u4e86\u4e00\u4e2a\u8282\u70b9D,\u6309\u7167\u4e0a\u9762\u7684\u89c4\u5219, \u5b9e\u9645\u4e0a\u662f\u8981\u6dfb\u52a0 D \u7684\u865a\u62df\u8282\u70b9, D1,D2,D3,\u7136\u540e\u6563\u5217\u6620\u5c04\u5230\u6570\u7ec4\u4e0a,\u5982\u4e0b\u56fe\u6240\u793a:<\/p>\n<p><img decoding=\"async\" class=\"medium-zoom-image\" src=\"http:\/\/blog.nonot.cn\/wp-content\/uploads\/2021\/08\/ec576-clipboard_20210814_113211.png\" alt=\"\" \/><\/p>\n<p>\u5148\u770b\u6700\u5de6\u8fb9, D1 \u63d2\u5165\u5230\u4e86 C2 \u548c A1 \u4e4b\u95f4, \u800cA1\u548cA\u8282\u70b9\u5bf9\u5e94, D1\u8282\u70b9\u548cD\u8282\u70b9\u5bf9\u5e94, \u4e5f\u5c31\u662f\u8bf4A\u8282\u70b9\u7684\u4e00\u90e8\u5206\u6570\u636e\u8981\u8fc1\u79fb\u5230D\u8282\u70b9, \u8fd9\u91cc\u6211\u7684\u601d\u8def\u662f, \u5f53\u5728\u8282\u70b9\u5199\u5165\u6570\u636e\u65f6, \u540c\u65f6\u628a\u865a\u62df\u8282\u70b9\u7684\u4fe1\u606f\u4e5f\u8bb0\u5f55\u4e0b\u6765,\u8fd9\u6837\u5c31\u5f88\u65b9\u4fbf\u505a\u6570\u636e\u8fc1\u79fb\u4e86, \u6211\u4eec\u53ef\u4ee5\u5728A\u8282\u70b9\u4e2d\u53ea\u627e\u51faA1\u865a\u62df\u8282\u70b9\u7684\u6570\u636e, \u800c\u4e0d\u662f\u5168\u90e8, \u7136\u540eHash\u8ba1\u7b97\u6620\u5c04\u540e, \u6839\u636e\u8ba1\u7b97\u7ed3\u679c,\u4e00\u90e8\u5206\u540c\u6b65\u5230D\u8282\u70b9, \u4e00\u90e8\u5206\u4fdd\u6301\u4e0d\u53d8\u3002\u540e\u8fb9\u7684\u6570\u636e\u4e5f\u53ef\u4ee5\u6309\u7167\u8fd9\u4e2a\u601d\u8def\u8fdb\u884c\u6570\u636e\u8fc1\u79fb\u3002<\/p>\n<p><strong>\u8282\u70b9\u51cf\u5c11<\/strong><\/p>\n<p><img decoding=\"async\" class=\"medium-zoom-image\" src=\"http:\/\/blog.nonot.cn\/wp-content\/uploads\/2021\/08\/22808-clipboard_20210814_115155.png\" alt=\"\" \/><\/p>\n<p>\u5f53C\u8282\u70b9\u4e0b\u7ebf\u7684\u65f6\u5019, \u6211\u4eec\u540c\u65f6\u8981\u79fb\u9664\u548cC\u8282\u70b9\u5bf9\u5e94\u7684\u865a\u62df\u8282\u70b9,C1,C2,C3, \u7136\u540e\u5c31\u662f\u6570\u636e\u8fc1\u79fb\u7684\u5de5\u4f5c\u4e86, \u6839\u636e\u56fe\u4e2d\u7684\u8868\u793a, \u53ef\u4ee5\u76f4\u63a5\u628a C\u8282\u70b9\u4e2d\u7684C2\u8282\u70b9\u7684\u6570\u636e\u8fc1\u79fb\u5230A1\u8282\u70b9, C1\u8fc1\u79fb\u5230B3,C3\u8fc1\u79fb\u5230B1\u4e2d, \u5b8c\u6210\uff01<\/p>\n<h2 id=\"\u603b\u7ed3\">\u603b\u7ed3<\/h2>\n<p>\u672c\u6587\u4ecb\u7ecd\u4e86\u54c8\u5e0c\u548c\u4e00\u81f4\u6027\u54c8\u5e0c\u7b97\u6cd5, \u4ee5\u53ca\u63d0\u4f9b\u4e86\u4e00\u4e9b\u6570\u636e\u8fc1\u79fb\u7684\u601d\u8def, \u56de\u987e\u4e0b\u8fd9\u4e2a\u65b9\u6848, \u9996\u5148\u9700\u8981\u5b9a\u4e49\u4e00\u4e2a\u6bd4\u8f83\u5927\u7684\u56fa\u5b9a\u503c\u7528\u4e8e\u53d6\u6a21, \u7136\u540e\u521b\u5efa\u548c\u771f\u5b9e\u8282\u70b9\u5bf9\u5e94\u7684\u865a\u62df\u8282\u70b9, \u6700\u540e\u518d\u628a\u865a\u62df\u8282\u70b9\u6620\u5c04\u5230\u6570\u7ec4\u4e0a, \u901a\u8fc7\u8303\u56f4\u533a\u95f4\u7684\u65b9\u6cd5, \u6765\u786e\u5b9a\u56fe\u7247\u5c5e\u4e8e\u54ea\u4e00\u4e2a\u5b58\u50a8\u8282\u70b9\u3002<\/p>\n<p>\u53ef\u80fd\u8fd8\u6709\u540c\u5b66\u4f1a\u8bf4, \u4e00\u81f4\u6027hash\u4e5f\u6709\u7f13\u5b58\u5931\u6548\u7684\u65f6\u5019,\u4e5f\u9700\u8981\u624b\u52a8\u8fc1\u79fb\u6570\u636e\u3002 \u662f\u7684, \u7ef4\u57fa\u767e\u79d1\u5bf9\u4e00\u81f4\u6027Hash\u7684\u5b9a\u4e49\u662f, \u5f53\u8282\u70b9\u7684\u6570\u91cf\u53d8\u52a8\u65f6,\u53ef\u4ee5\u5141\u8bb8\u5c11\u90e8\u5206\u7684\u6570\u636e\u8fdb\u884c\u8fc1\u79fb, \u800c\u5927\u90e8\u5206\u7684\u6570\u636e\u8fd8\u662f\u4e0d\u53d8\u7684\u3002<\/p>\n<p>\u4e0a\u9762\u7684\u4e00\u81f4\u6027Hash\u7b97\u6cd5\u5176\u5b9e\u662f\u7ecf\u5178\u7684\u54c8\u5e0c\u73af\u7b97\u6cd5, \u5f53\u7136\u8fd8\u6709\u5176\u4ed6\u7684\u7b97\u6cd5, \u6bd4\u5982\u8df3\u8dc3\u4e00\u81f4\u6027\u54c8\u5e0c\u6cd5, \u6709\u5174\u8da3\u4e5f\u53ef\u4ee5\u770b\u4e00\u4e0b, \u4ee5\u4e0a\u5185\u5bb9\u5747\u4e3a\u4e2a\u4eba\u7406\u89e3, \u5982\u679c\u9519\u8bef, \u53ef\u4ee5\u6307\u51fa, \u5e0c\u671b\u5bf9\u60a8\u6709\u7528\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u54c8\u5e0c Hash \u7b97\u6cd5\u4ecb\u7ecd \u54c8\u5e0c\u7b97\u6cd5\u4e5f\u53eb\u6563\u5217\u7b97\u6cd5, \u4e0d\u8fc7\u82f1\u6587\u5355&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-282","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/blog.nonot.cn\/index.php\/wp-json\/wp\/v2\/posts\/282","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.nonot.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.nonot.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.nonot.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.nonot.cn\/index.php\/wp-json\/wp\/v2\/comments?post=282"}],"version-history":[{"count":0,"href":"https:\/\/blog.nonot.cn\/index.php\/wp-json\/wp\/v2\/posts\/282\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.nonot.cn\/index.php\/wp-json\/wp\/v2\/media?parent=282"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.nonot.cn\/index.php\/wp-json\/wp\/v2\/categories?post=282"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.nonot.cn\/index.php\/wp-json\/wp\/v2\/tags?post=282"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}