{"id":45945,"date":"2024-12-01T11:48:03","date_gmt":"2024-12-01T03:48:03","guid":{"rendered":"https:\/\/fwq.ai\/blog\/45945\/"},"modified":"2024-12-01T11:48:03","modified_gmt":"2024-12-01T03:48:03","slug":"%e4%bd%bf%e7%94%a8-koa-%e4%b8%ad-md5-update-%e5%87%bd%e6%95%b0%e4%bc%a0%e9%80%92%e5%8f%98%e9%87%8f%e6%97%b6%e5%a6%82%e4%bd%95%e9%81%bf%e5%85%8d%e5%86%85%e9%83%a8%e6%9c%8d%e5%8a%a1%e5%99%a8%e9%94%99-3","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/45945\/","title":{"rendered":"\u4f7f\u7528 Koa \u4e2d md5.update \u51fd\u6570\u4f20\u9012\u53d8\u91cf\u65f6\u5982\u4f55\u907f\u514d\u5185\u90e8\u670d\u52a1\u5668\u9519\u8bef\uff1f"},"content":{"rendered":"<p><b><\/b> <\/p>\n<h1>\u4f7f\u7528 Koa \u4e2d md5.update \u51fd\u6570\u4f20\u9012\u53d8\u91cf\u65f6\u5982\u4f55\u907f\u514d\u5185\u90e8\u670d\u52a1\u5668\u9519\u8bef\uff1f<\/h1>\n<p>\u5927\u5bb6\u597d\uff0c\u6211\u4eec\u53c8\u89c1\u9762\u4e86\u554a~\u672c\u6587\u7684\u5185\u5bb9\u4e2d\u5c06\u4f1a\u6d89\u53ca\u5230\u7b49\u7b49\u3002\u5982\u679c\u4f60\u6b63\u5728\u5b66\u4e60\u76f8\u5173\u77e5\u8bc6\uff0c\u6b22\u8fce\u5173\u6ce8\u6211\uff0c\u4ee5\u540e\u4f1a\u7ed9\u5927\u5bb6\u5e26\u6765\u66f4\u591a\u76f8\u5173\u6587\u7ae0\uff0c\u5e0c\u671b\u6211\u4eec\u80fd\u4e00\u8d77\u8fdb\u6b65\uff01\u4e0b\u9762\u5c31\u5f00\u59cb\u672c\u6587\u7684\u6b63\u5f0f\u5185\u5bb9~<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.17golang.com\/uploads\/20241120\/1732110876673dea1cbb72a.jpg\" class=\"aligncenter\" title=\"\u4f7f\u7528 Koa \u4e2d md5.update \u51fd\u6570\u4f20\u9012\u53d8\u91cf\u65f6\u5982\u4f55\u907f\u514d\u5185\u90e8\u670d\u52a1\u5668\u9519\u8bef\uff1f\u63d2\u56fe\" alt=\"\u4f7f\u7528 Koa \u4e2d md5.update \u51fd\u6570\u4f20\u9012\u53d8\u91cf\u65f6\u5982\u4f55\u907f\u514d\u5185\u90e8\u670d\u52a1\u5668\u9519\u8bef\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong>koa md5.update \u53d8\u91cf\u4f20\u9012\u5f15\u53d1\u5185\u90e8\u670d\u52a1\u5668\u9519\u8bef<\/strong><\/p>\n<p>\u5728 koa \u4e2d\u4f7f\u7528 md5.update \u51fd\u6570\u65f6\uff0c\u5982\u679c\u4f20\u9012\u53d8\u91cf\uff0c\u53ef\u80fd\u4f1a\u9047\u5230\u5185\u90e8\u670d\u52a1\u5668\u9519\u8bef\u3002<\/p>\n<p>\u8be5\u95ee\u9898\u53ef\u80fd\u662f\u7531\u4e8e\u4ee5\u4e0b\u539f\u56e0\u9020\u6210\u7684\uff1a<\/p>\n<ul>\n<li><strong>\u53d8\u91cf\u7c7b\u578b\u9519\u8bef\uff1a<\/strong>md5.update \u51fd\u6570\u9700\u8981\u5b57\u7b26\u4e32\u7c7b\u578b\u7684\u8f93\u5165\uff0c\u800c\u5982\u679c\u4f20\u9012\u7684\u53d8\u91cf\u4e0d\u662f\u5b57\u7b26\u4e32\uff0c\u5c31\u4f1a\u89e6\u53d1\u9519\u8bef\u3002<\/li>\n<li><strong>\u53d8\u91cf\u503c\u9519\u8bef\uff1a<\/strong>\u4f20\u9012\u7684\u53d8\u91cf\u503c\u53ef\u80fd\u6709\u7279\u6b8a\u5b57\u7b26\u6216\u6362\u884c\u7b26\uff0c\u5bfc\u81f4 md5 \u5904\u7406\u9519\u8bef\u3002<\/li>\n<\/ul>\n<p><strong>\u89e3\u51b3\u65b9\u6848\uff1a<\/strong><\/p>\n<p>\u8981\u89e3\u51b3\u6b64\u95ee\u9898\uff0c\u53ef\u4ee5\u91c7\u53d6\u4ee5\u4e0b\u6b65\u9aa4\uff1a<\/p>\n<ul>\n<li><strong>\u68c0\u67e5\u53d8\u91cf\u7c7b\u578b\uff1a<\/strong>\u786e\u4fdd\u4f20\u9012\u7ed9 md5.update \u51fd\u6570\u7684\u53d8\u91cf\u662f\u5b57\u7b26\u4e32\u7c7b\u578b\u3002\u53ef\u4ee5\u4f7f\u7528 typeof \u8fd0\u7b97\u7b26\u8fdb\u884c\u68c0\u67e5\u3002<\/li>\n<li><strong>\u8f6c\u6362\u53d8\u91cf\u503c\uff1a<\/strong>\u5982\u679c\u53d8\u91cf\u503c\u4e0d\u662f\u5b57\u7b26\u4e32\uff0c\u53ef\u4ee5\u901a\u8fc7\u4f7f\u7528 tostring \u65b9\u6cd5\u5c06\u5176\u8f6c\u6362\u4e3a\u5b57\u7b26\u4e32\u3002<\/li>\n<li><strong>\u68c0\u67e5\u7279\u6b8a\u5b57\u7b26\uff1a<\/strong>\u786e\u4fdd\u53d8\u91cf\u503c\u4e2d\u6ca1\u6709\u7279\u6b8a\u5b57\u7b26\u6216\u6362\u884c\u7b26\u3002\u5982\u679c\u5b58\u5728\uff0c\u53ef\u4ee5\u5c06\u5176\u66ff\u6362\u4e3a\u8f6c\u4e49\u7b26\u6216\u901a\u8fc7\u6b63\u5219\u8868\u8fbe\u5f0f\u79fb\u9664\u3002<\/li>\n<\/ul>\n<p><strong>\u4fee\u6539\u540e\u7684\u4ee3\u7801\uff1a<\/strong><\/p>\n<pre>const md5password = (password) =&gt; {\n  const md5 = crypto.createHash('md5');\n  const result = md5.update(password.toString()).digest('hex');\n  console.log(result);\n};<\/pre>\n<p>\u4ee5\u4e0a\u5c31\u662f\u300a\u4f7f\u7528 Koa \u4e2d md5.update \u51fd\u6570\u4f20\u9012\u53d8\u91cf\u65f6\u5982\u4f55\u907f\u514d\u5185\u90e8\u670d\u52a1\u5668\u9519\u8bef\uff1f\u300b\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u5173\u4e8e\u7684\u8d44\u6599\u8bf7\u5173\u6ce8\u7c73\u4e91\u516c\u4f17\u53f7\uff01<\/p>\n<dl>\n<dt>\n <\/dt>\n<\/dl>\n","protected":false},"excerpt":{"rendered":"<p>\u4f7f\u7528 Koa \u4e2d md5.update \u51fd\u6570\u4f20\u9012\u53d8\u91cf\u65f6\u5982\u4f55\u907f\u514d\u5185\u90e8\u670d\u52a1\u5668\u9519\u8bef\uff1f \u5927\u5bb6\u597d\uff0c\u6211\u4eec\u53c8\u89c1\u9762\u4e86\u554a~\u672c\u6587\u7684\u5185\u5bb9\u4e2d\u5c06\u4f1a\u6d89\u53ca\u5230\u7b49\u7b49\u3002\u5982\u679c\u4f60\u6b63\u5728\u5b66\u4e60\u76f8\u5173\u77e5\u8bc6\uff0c\u6b22\u8fce\u5173\u6ce8\u6211\uff0c\u4ee5\u540e\u4f1a\u7ed9\u5927\u5bb6\u5e26\u6765\u66f4\u591a\u76f8\u5173\u6587\u7ae0\uff0c\u5e0c\u671b\u6211\u4eec\u80fd\u4e00\u8d77\u8fdb\u6b65\uff01\u4e0b\u9762\u5c31\u5f00\u59cb\u672c\u6587\u7684\u6b63\u5f0f\u5185\u5bb9~ koa md5.update \u53d8\u91cf\u4f20\u9012\u5f15\u53d1\u5185\u90e8\u670d\u52a1\u5668\u9519\u8bef \u5728 koa \u4e2d\u4f7f\u7528 md5.update \u51fd\u6570\u65f6\uff0c\u5982\u679c\u4f20\u9012\u53d8\u91cf\uff0c\u53ef\u80fd\u4f1a\u9047\u5230\u5185\u90e8\u670d\u52a1\u5668\u9519\u8bef\u3002 \u8be5\u95ee\u9898\u53ef\u80fd\u662f\u7531\u4e8e\u4ee5\u4e0b\u539f\u56e0\u9020\u6210\u7684\uff1a \u53d8\u91cf\u7c7b\u578b\u9519\u8bef\uff1amd5.update \u51fd\u6570\u9700\u8981\u5b57\u7b26\u4e32\u7c7b\u578b\u7684\u8f93\u5165\uff0c\u800c\u5982\u679c\u4f20\u9012\u7684\u53d8\u91cf\u4e0d\u662f\u5b57\u7b26\u4e32\uff0c\u5c31\u4f1a\u89e6\u53d1\u9519\u8bef\u3002 \u53d8\u91cf\u503c\u9519\u8bef\uff1a\u4f20\u9012\u7684\u53d8\u91cf\u503c\u53ef\u80fd\u6709\u7279\u6b8a\u5b57\u7b26\u6216\u6362\u884c\u7b26\uff0c\u5bfc\u81f4 md5 \u5904\u7406\u9519\u8bef\u3002 \u89e3\u51b3\u65b9\u6848\uff1a \u8981\u89e3\u51b3\u6b64\u95ee\u9898\uff0c\u53ef\u4ee5\u91c7\u53d6\u4ee5\u4e0b\u6b65\u9aa4\uff1a \u68c0\u67e5\u53d8\u91cf\u7c7b\u578b\uff1a\u786e\u4fdd\u4f20\u9012\u7ed9 md5.update \u51fd\u6570\u7684\u53d8\u91cf\u662f\u5b57\u7b26\u4e32\u7c7b\u578b\u3002\u53ef\u4ee5\u4f7f\u7528 typeof \u8fd0\u7b97\u7b26\u8fdb\u884c\u68c0\u67e5\u3002 \u8f6c\u6362\u53d8\u91cf\u503c\uff1a\u5982\u679c\u53d8\u91cf\u503c\u4e0d\u662f\u5b57\u7b26\u4e32\uff0c\u53ef\u4ee5\u901a\u8fc7\u4f7f\u7528 tostring \u65b9\u6cd5\u5c06\u5176\u8f6c\u6362\u4e3a\u5b57\u7b26\u4e32\u3002 \u68c0\u67e5\u7279\u6b8a\u5b57\u7b26\uff1a\u786e\u4fdd\u53d8\u91cf\u503c\u4e2d\u6ca1\u6709\u7279\u6b8a\u5b57\u7b26\u6216\u6362\u884c\u7b26\u3002\u5982\u679c\u5b58\u5728\uff0c\u53ef\u4ee5\u5c06\u5176\u66ff\u6362\u4e3a\u8f6c\u4e49\u7b26\u6216\u901a\u8fc7\u6b63\u5219\u8868\u8fbe\u5f0f\u79fb\u9664\u3002 \u4fee\u6539\u540e\u7684\u4ee3\u7801\uff1a const md5password = (password) =&gt; { const md5 = crypto.createHash(&#8216;md5&#8217;); const result = md5.update(password.toString()).digest(&#8216;hex&#8217;); console.log(result); }; \u4ee5\u4e0a\u5c31\u662f\u300a\u4f7f\u7528 Koa \u4e2d md5.update \u51fd\u6570\u4f20\u9012\u53d8\u91cf\u65f6\u5982\u4f55\u907f\u514d\u5185\u90e8\u670d\u52a1\u5668\u9519\u8bef\uff1f\u300b\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u5173\u4e8e\u7684\u8d44\u6599\u8bf7\u5173\u6ce8\u7c73\u4e91\u516c\u4f17\u53f7\uff01<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-45945","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/45945","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=45945"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/45945\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=45945"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=45945"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=45945"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}