{"id":49,"date":"2024-08-05T10:32:59","date_gmt":"2024-08-05T02:32:59","guid":{"rendered":"https:\/\/note.ui11.cc\/?p=49"},"modified":"2024-08-05T10:53:56","modified_gmt":"2024-08-05T02:53:56","slug":"%e5%af%86%e7%a0%81%e5%8a%a0%e5%af%86","status":"publish","type":"post","link":"https:\/\/note.ui11.cc\/index.php\/2024\/08\/05\/%e5%af%86%e7%a0%81%e5%8a%a0%e5%af%86\/","title":{"rendered":"\u5bc6\u7801\u52a0\u5bc6"},"content":{"rendered":"\n<p>1:\u5c06\u5bc6\u7801\u52a0\u5bc6\u540e\u5b58\u50a8\uff0c\u63d0\u9ad8\u5b89\u5168\u6027<\/p>\n\n\n\n<p>2:\u4f7f\u7528MD5\u52a0\u5bc6\u65b9\u5f0f\u5bf9\u660e\u6587\u5bc6\u7801\u52a0\u5bc6<\/p>\n\n\n\n<details class=\"wp-block-details is-layout-flow wp-block-details-is-layout-flow\"><summary>MD5<\/summary>\n<p>MD5\uff08Message-Digest Algorithm 5\uff09\u662f\u4e00\u79cd\u5e7f\u6cdb\u4f7f\u7528\u7684\u52a0\u5bc6\u6563\u5217\u51fd\u6570\uff0c\u5b83\u80fd\u591f\u4ea7\u751f\u4e00\u4e2a128\u4f4d\uff0816\u5b57\u8282\uff09\u7684\u6563\u5217\u503c\uff08\u54c8\u5e0c\u503c\uff09\uff0c\u901a\u5e38\u7528\u4e00\u4e2a32\u4f4d\u7684\u5341\u516d\u8fdb\u5236\u5b57\u7b26\u4e32\u8868\u793a\u3002MD5\u88ab\u8bbe\u8ba1\u7528\u6765\u786e\u4fdd\u4fe1\u606f\u4f20\u8f93\u5b8c\u6574\u4e00\u81f4\uff0c\u5e38\u7528\u4e8e\u9a8c\u8bc1\u6587\u4ef6\u7684\u5b8c\u6574\u6027\u3002<\/p>\n\n\n\n<p>MD5\u7684\u7279\u70b9\u5305\u62ec\uff1a<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>\u4e0d\u53ef\u9006\u6027<\/strong>\uff1a\u4eceMD5\u6563\u5217\u503c\u51e0\u4e4e\u4e0d\u53ef\u80fd\u53cd\u5411\u63a8\u5bfc\u51fa\u539f\u59cb\u6570\u636e\u3002<\/li>\n\n\n\n<li><strong>\u4e00\u81f4\u6027<\/strong>\uff1a\u76f8\u540c\u7684\u6570\u636e\u603b\u662f\u4ea7\u751f\u76f8\u540c\u7684MD5\u6563\u5217\u503c\u3002<\/li>\n\n\n\n<li><strong>\u5feb\u901f\u8ba1\u7b97<\/strong>\uff1aMD5\u7b97\u6cd5\u80fd\u591f\u5feb\u901f\u8ba1\u7b97\u51fa\u6570\u636e\u7684\u6563\u5217\u503c\u3002<\/li>\n<\/ol>\n\n\n\n<p>\u5c3d\u7ba1MD5\u5e7f\u6cdb\u4f7f\u7528\uff0c\u4f46\u5b83\u4e5f\u5b58\u5728\u4e00\u4e9b\u5b89\u5168\u95ee\u9898\u3002\u7531\u4e8eMD5\u7b97\u6cd5\u7684\u5f31\u70b9\uff0c\u5b83\u4e0d\u518d\u88ab\u8ba4\u4e3a\u662f\u5b89\u5168\u7684\u6563\u5217\u51fd\u6570\uff0c\u7279\u522b\u662f\u5728\u5bc6\u7801\u5b66\u5e94\u7528\u4e2d\u3002MD5\u5bb9\u6613\u53d7\u5230\u78b0\u649e\u653b\u51fb\uff0c\u5373\u627e\u5230\u4e24\u4e2a\u4e0d\u540c\u7684\u8f93\u5165\u6570\u636e\uff0c\u5b83\u4eec\u4ea7\u751f\u76f8\u540c\u7684MD5\u6563\u5217\u503c\u3002<\/p>\n\n\n\n<p>\u56e0\u6b64\uff0cMD5\u5728\u9700\u8981\u9ad8\u5b89\u5168\u6027\u7684\u573a\u5408\uff08\u5982\u5bc6\u7801\u5b58\u50a8\uff09\u4e2d\u4e0d\u518d\u63a8\u8350\u4f7f\u7528\u3002\u66ff\u4ee3\u7684\u6563\u5217\u51fd\u6570\uff0c\u5982SHA-256\uff0c\u63d0\u4f9b\u4e86\u66f4\u9ad8\u7684\u5b89\u5168\u6027\u3002<\/p>\n\n\n\n<p>\u5728\u7f16\u7a0b\u4e2d\uff0cMD5\u5e38\u7528\u4e8e\u9a8c\u8bc1\u6570\u636e\u7684\u5b8c\u6574\u6027\uff0c\u4f8b\u5982\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u786e\u8ba4\u6587\u4ef6\u4e0b\u8f7d\u7684\u5b8c\u6574\u6027\u3002<\/li>\n\n\n\n<li>\u68c0\u67e5\u6570\u636e\u5728\u4f20\u8f93\u8fc7\u7a0b\u4e2d\u662f\u5426\u88ab\u7be1\u6539\u3002<\/li>\n<\/ul>\n\n\n\n<p class=\"has-vivid-cyan-blue-color has-text-color has-link-color wp-elements-4206975540bd046d8a456778a7ace00c\">\u5728PHP\u4e2d\uff0c\u53ef\u4ee5\u4f7f\u7528\u5185\u7f6e\u7684&nbsp;<code>md5()<\/code>&nbsp;\u51fd\u6570\u6765\u751f\u6210\u6570\u636e\u7684MD5\u6563\u5217\u503c\uff1a<\/p>\n\n\n\n<p class=\"has-vivid-cyan-blue-color has-text-color has-link-color wp-elements-fbd48d67f63dfae3a36ac2b99bd38eb1\"><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$data = \"Hello, World!\";\n$md5Hash = md5($data);\necho $md5Hash; \/\/ \u8f93\u51fa\u6570\u636e\u7684MD5\u6563\u5217\u503c<\/code><\/pre>\n<\/details>\n\n\n\n<details class=\"wp-block-details is-layout-flow wp-block-details-is-layout-flow\"><summary>SHA-256<\/summary>\n<p>\u662f\u4e00\u79cd\u52a0\u5bc6\u6563\u5217\u51fd\u6570\uff0c\u5c5e\u4e8eSHA-2\uff08Secure Hash Algorithm 2\uff09\u5bb6\u65cf\u7684\u4e00\u90e8\u5206\u3002SHA-256\u80fd\u591f\u4ea7\u751f\u4e00\u4e2a256\u4f4d\uff0832\u5b57\u8282\uff09\u7684\u6563\u5217\u503c\uff0c\u901a\u5e38\u8868\u793a\u4e3a\u4e00\u4e2a64\u5b57\u7b26\u7684\u5341\u516d\u8fdb\u5236\u5b57\u7b26\u4e32\u3002\u4e0eMD5\u76f8\u6bd4\uff0cSHA-256\u63d0\u4f9b\u4e86\u66f4\u9ad8\u7684\u5b89\u5168\u6027\uff0c\u56e0\u4e3a\u5b83\u66f4\u96be\u88ab\u7834\u89e3\u6216\u906d\u53d7\u78b0\u649e\u653b\u51fb\u3002<\/p>\n\n\n\n<p>SHA-256\u7684\u4e3b\u8981\u7279\u70b9\u5305\u62ec\uff1a<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>\u5b89\u5168\u6027<\/strong>\uff1aSHA-256\u88ab\u8ba4\u4e3a\u662f\u975e\u5e38\u5b89\u5168\u7684\u6563\u5217\u51fd\u6570\uff0c\u9002\u7528\u4e8e\u9700\u8981\u9ad8\u5b89\u5168\u6027\u7684\u573a\u5408\u3002<\/li>\n\n\n\n<li><strong>\u4e00\u81f4\u6027<\/strong>\uff1a\u76f8\u540c\u7684\u6570\u636e\u603b\u662f\u4ea7\u751f\u76f8\u540c\u7684SHA-256\u6563\u5217\u503c\u3002<\/li>\n\n\n\n<li><strong>\u4e0d\u53ef\u9006\u6027<\/strong>\uff1a\u4eceSHA-256\u6563\u5217\u503c\u51e0\u4e4e\u4e0d\u53ef\u80fd\u53cd\u5411\u63a8\u5bfc\u51fa\u539f\u59cb\u6570\u636e<\/li>\n\n\n\n<li><strong>\u6297\u78b0\u649e<\/strong>\uff1a\u4e0eMD5\u76f8\u6bd4\uff0cSHA-256\u66f4\u96be\u906d\u53d7\u78b0\u649e\u653b\u51fb\u3002<\/li>\n\n\n\n<li>SHA-256\u5e38\u7528\u4e8e\u4ee5\u4e0b\u573a\u5408\uff1a<\/li>\n\n\n\n<li><strong>\u5bc6\u7801\u5b58\u50a8<\/strong>\uff1a\u5728\u5b58\u50a8\u5bc6\u7801\u65f6\uff0c\u901a\u5e38\u4f1a\u4f7f\u7528SHA-256\u6563\u5217\u51fd\u6570\u6765\u5b58\u50a8\u5bc6\u7801\u7684\u6563\u5217\u503c\uff0c\u800c\u4e0d\u662f\u5b58\u50a8\u660e\u6587\u5bc6\u7801\u3002<\/li>\n\n\n\n<li><strong>\u6570\u5b57\u7b7e\u540d<\/strong>\uff1aSHA-256\u6563\u5217\u503c\u5e38\u7528\u4e8e\u6570\u5b57\u7b7e\u540d\uff0c\u4ee5\u9a8c\u8bc1\u6570\u636e\u7684\u5b8c\u6574\u6027\u548c\u6765\u6e90\u3002<\/li>\n\n\n\n<li><strong>\u533a\u5757\u94fe\u6280\u672f<\/strong>\uff1a\u5728\u533a\u5757\u94fe\u6280\u672f\u4e2d\uff0cSHA-256\u7528\u4e8e\u521b\u5efa\u533a\u5757\u7684\u54c8\u5e0c\u503c\uff0c\u786e\u4fdd\u533a\u5757\u94fe\u7684\u5b89\u5168\u6027\u548c\u5b8c\u6574\u6027\u3002<\/li>\n<\/ol>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n<\/details>\n\n\n\n<figure class=\"wp-block-image size-full\"><div class='fancybox-wrapper lazyload-container-unload' data-fancybox='post-images' href='https:\/\/note.ui11.cc\/wp-content\/uploads\/2024\/08\/image-8.png'><img class=\"lazyload lazyload-style-1\" src=\"data:image\/svg+xml;base64,PCEtLUFyZ29uTG9hZGluZy0tPgo8c3ZnIHdpZHRoPSIxIiBoZWlnaHQ9IjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgc3Ryb2tlPSIjZmZmZmZmMDAiPjxnPjwvZz4KPC9zdmc+\"  loading=\"lazy\" decoding=\"async\" width=\"979\" height=\"158\" data-original=\"https:\/\/note.ui11.cc\/wp-content\/uploads\/2024\/08\/image-8.png\" src=\"data:image\/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAANSURBVBhXYzh8+PB\/AAffA0nNPuCLAAAAAElFTkSuQmCC\" alt=\"\" class=\"wp-image-50\"  sizes=\"auto, (max-width: 979px) 100vw, 979px\" \/><\/div><\/figure>\n\n\n\n<details class=\"wp-block-details is-layout-flow wp-block-details-is-layout-flow\"><summary>getBytes()<\/summary>\n<p><code>getBytes()<\/code>\u00a0\u662f Java \u4e2d\u00a0<code>String<\/code>\u00a0\u7c7b\u7684\u4e00\u4e2a\u65b9\u6cd5\uff0c\u7528\u4e8e\u5c06\u5b57\u7b26\u4e32\u8f6c\u6362\u6210\u5b57\u8282\u6570\u7ec4\u3002\u8fd9\u4e2a\u65b9\u6cd5\u975e\u5e38\u6709\u7528\uff0c\u7279\u522b\u662f\u5728\u9700\u8981\u5c06\u5b57\u7b26\u4e32\u4ee5\u7279\u5b9a\u7684\u5b57\u7b26\u7f16\u7801\u8f6c\u6362\u4e3a\u5b57\u8282\u5e8f\u5217\u65f6\u3002\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c\u5982\u679c\u6ca1\u6709\u6307\u5b9a\u5b57\u7b26\u7f16\u7801\uff0c<code>getBytes()<\/code>\u00a0\u65b9\u6cd5\u4f1a\u4f7f\u7528\u5e73\u53f0\u9ed8\u8ba4\u7684\u5b57\u7b26\u7f16\u7801\u6765\u8f6c\u6362\u5b57\u7b26\u4e32\u3002<code>getBytes()<\/code>&nbsp;\u65b9\u6cd5\u6709\u51e0\u79cd\u4e0d\u540c\u7684\u91cd\u8f7d\u5f62\u5f0f\uff0c\u5141\u8bb8\u4f60\u6307\u5b9a\u5b57\u7b26\u7f16\u7801\u6216\u5b57\u7b26\u96c6\u3002\u4ee5\u4e0b\u662f\u4e00\u4e9b\u5e38\u89c1\u7684\u91cd\u8f7d\u5f62\u5f0f\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>String str = \"Hello, World!\";\nbyte&#91;] bytes = str.getBytes();\n\u4f7f\u7528\u6307\u5b9a\u5b57\u7b26\u96c6\nString str = \"Hello, World!\";\nbyte&#91;] bytes = str.getBytes(StandardCharsets.UTF_8);\n\u6ce8\u610f\u4e8b\u9879\n\u5b57\u7b26\u7f16\u7801\uff1a\u9009\u62e9\u6b63\u786e\u7684\u5b57\u7b26\u7f16\u7801\u975e\u5e38\u91cd\u8981\uff0c\u7279\u522b\u662f\u5f53\u5b57\u7b26\u4e32\u5305\u542b\u975eASCII\u5b57\u7b26\u65f6\u3002\u4e0d\u540c\u7684\u5b57\u7b26\u7f16\u7801\u53ef\u80fd\u4f1a\u5bfc\u81f4\u4e0d\u540c\u7684\u5b57\u8282\u5e8f\u5217\uff0c\u751a\u81f3\u53ef\u80fd\u5bfc\u81f4\u6570\u636e\u635f\u574f\u3002\n\u5e73\u53f0\u4f9d\u8d56\u6027\uff1a\u9ed8\u8ba4\u5b57\u7b26\u7f16\u7801\u4f9d\u8d56\u4e8e\u5e73\u53f0\uff0c\u8fd9\u610f\u5473\u7740\u5728\u4e0d\u540c\u7684\u64cd\u4f5c\u7cfb\u7edf\u6216\u914d\u7f6e\u4e2d\uff0c\u76f8\u540c\u7684\u5b57\u7b26\u4e32\u53ef\u80fd\u4f1a\u4ea7\u751f\u4e0d\u540c\u7684\u5b57\u8282\u5e8f\u5217\u3002\n\u9519\u8bef\u5904\u7406\uff1a\u5982\u679c\u6307\u5b9a\u7684\u5b57\u7b26\u7f16\u7801\u4e0d\u88ab\u652f\u6301\uff0cgetBytes() \u65b9\u6cd5\u5c06\u629b\u51fa UnsupportedEncodingException\u3002\u56e0\u6b64\uff0c\u4f7f\u7528\u65f6\u53ef\u80fd\u9700\u8981\u5904\u7406\u8fd9\u4e2a\u5f02\u5e38\u3002<\/code><\/pre>\n<\/details>\n\n\n\n<p>DigestUtils.md5DigestAsHex<\/p>\n\n\n\n<p><code>DigestUtils.md5DigestAsHex<\/code>\u00a0\u65b9\u6cd5\u63a5\u53d7\u4e00\u4e2a\u5b57\u8282\u6570\u7ec4\u4f5c\u4e3a\u8f93\u5165\uff08\u901a\u8fc7\u00a0<code>data.getBytes()<\/code>\u00a0\u8f6c\u6362\uff09\uff0c\u7136\u540e\u8fd4\u56de\u8be5\u6570\u636e\u7684MD5\u6563\u5217\u503c\u7684\u5341\u516d\u8fdb\u5236\u8868\u793a<\/p>\n\n\n\n<details class=\"wp-block-details is-layout-flow wp-block-details-is-layout-flow\"><summary>ASCII\u7f16\u7801<\/summary>\n<p>ASCII\u7f16\u7801\u4f7f\u75287\u4f4d\u4e8c\u8fdb\u5236\u6570\uff08bit\uff09\u6765\u8868\u793a\u5b57\u7b26\uff0c\u56e0\u6b64\u5b83\u53ef\u4ee5\u8868\u793a128\u4e2a\u4e0d\u540c\u7684\u5b57\u7b26\uff0c\u5305\u62ec\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u82f1\u6587\u5927\u5c0f\u5199\u5b57\u6bcd\uff08A-Z, a-z\uff09<\/li>\n\n\n\n<li>\u6570\u5b57\uff080-9\uff09<\/li>\n\n\n\n<li>\u6807\u70b9\u7b26\u53f7\u548c\u7279\u6b8a\u5b57\u7b26\uff08\u5982\u7a7a\u683c\u3001\u6807\u70b9\u7b26\u53f7\u3001\u8d27\u5e01\u7b26\u53f7\u7b49\uff09<\/li>\n\n\n\n<li>\u63a7\u5236\u5b57\u7b26\uff08\u5982\u6362\u884c\u7b26\u3001\u56de\u8f66\u7b26\u7b49\uff09<\/li>\n<\/ul>\n\n\n\n<p>\u7531\u4e8eASCII\u53ea\u4f7f\u75287\u4f4d\u4e8c\u8fdb\u5236\u6570\uff0c\u5b83\u80fd\u591f\u8868\u793a\u7684\u5b57\u7b26\u6570\u91cf\u6709\u9650\uff0c\u56e0\u6b64\u5b83\u4e3b\u8981\u9002\u7528\u4e8e\u8868\u793a\u82f1\u6587\u6587\u672c\u548c\u4e00\u4e9b\u57fa\u672c\u7684\u7b26\u53f7\u3002\u5bf9\u4e8e\u5176\u4ed6\u8bed\u8a00\u548c\u5b57\u7b26\u96c6\uff0c\u5982\u4e2d\u6587\u3001\u65e5\u6587\u7b49\uff0cASCII\u65e0\u6cd5\u76f4\u63a5\u8868\u793a\uff0c\u9700\u8981\u4f7f\u7528\u5176\u4ed6\u7f16\u7801\u6807\u51c6\uff0c\u5982Unicode\u3002<\/p>\n\n\n\n<p>\u5728\u7f16\u7a0b\u4e2d\uff0cASCII\u5b57\u7b26\u4e32\u901a\u5e38\u7528\u4e8e\u5904\u7406\u82f1\u6587\u6587\u672c\u6570\u636e\u3002\u4f8b\u5982\uff0c\u5728\u8bb8\u591a\u7f16\u7a0b\u8bed\u8a00\u4e2d\uff0c\u5b57\u7b26\u4e32\u5b57\u9762\u91cf\u9ed8\u8ba4\u4f7f\u7528ASCII\u7f16\u7801\u3002\u5bf9\u4e8e\u9700\u8981\u5904\u7406\u975eASCII\u5b57\u7b26\u7684\u573a\u666f\uff0c\u901a\u5e38\u4f1a\u4f7f\u7528\u6269\u5c55\u7684\u5b57\u7b26\u7f16\u7801\u6807\u51c6\uff0c\u5982UTF-8\u3001UTF-16\u7b49\u3002<\/p>\n<\/details>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>1:\u5c06\u5bc6\u7801\u52a0\u5bc6\u540e\u5b58\u50a8\uff0c\u63d0\u9ad8\u5b89\u5168\u6027 2:\u4f7f\u7528MD5\u52a0\u5bc6\u65b9\u5f0f\u5bf9\u660e\u6587\u5bc6\u7801\u52a0\u5bc6 DigestUtils.md5Dige [&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":[],"class_list":["post-49","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/note.ui11.cc\/index.php\/wp-json\/wp\/v2\/posts\/49","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/note.ui11.cc\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/note.ui11.cc\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/note.ui11.cc\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/note.ui11.cc\/index.php\/wp-json\/wp\/v2\/comments?post=49"}],"version-history":[{"count":2,"href":"https:\/\/note.ui11.cc\/index.php\/wp-json\/wp\/v2\/posts\/49\/revisions"}],"predecessor-version":[{"id":61,"href":"https:\/\/note.ui11.cc\/index.php\/wp-json\/wp\/v2\/posts\/49\/revisions\/61"}],"wp:attachment":[{"href":"https:\/\/note.ui11.cc\/index.php\/wp-json\/wp\/v2\/media?parent=49"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/note.ui11.cc\/index.php\/wp-json\/wp\/v2\/categories?post=49"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/note.ui11.cc\/index.php\/wp-json\/wp\/v2\/tags?post=49"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}