{"id":53545,"date":"2024-12-03T15:46:50","date_gmt":"2024-12-03T07:46:50","guid":{"rendered":"https:\/\/fwq.ai\/blog\/53545\/"},"modified":"2024-12-03T15:46:50","modified_gmt":"2024-12-03T07:46:50","slug":"flutter-%e5%a6%82%e4%bd%95%e4%bd%bf%e7%94%a8-encrypt-%e5%ba%93%e5%ae%9e%e7%8e%b0-aes-%e5%8a%a0%e5%af%86%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/53545\/","title":{"rendered":"Flutter \u5982\u4f55\u4f7f\u7528 encrypt \u5e93\u5b9e\u73b0 AES \u52a0\u5bc6\uff1f"},"content":{"rendered":"<p><b><\/b>     <\/p>\n<h1>Flutter \u5982\u4f55\u4f7f\u7528 encrypt \u5e93\u5b9e\u73b0 AES \u52a0\u5bc6\uff1f<\/h1>\n<p>\u5927\u5bb6\u597d\uff0c\u4eca\u5929\u672c\u4eba\u7ed9\u5927\u5bb6\u5e26\u6765\u6587\u7ae0<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\">\u300aFlutter \u5982\u4f55\u4f7f\u7528 encrypt \u5e93\u5b9e\u73b0 AES \u52a0\u5bc6\uff1f\u300b<\/span>\uff0c\u6587\u4e2d\u5185\u5bb9\u4e3b\u8981\u6d89\u53ca\u5230<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\"><span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\"><\/span><\/span>\uff0c\u5982\u679c\u4f60\u5bf9<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\">\u6587\u7ae0<\/span>\u65b9\u9762\u7684\u77e5\u8bc6\u70b9\u611f\u5174\u8da3\uff0c\u90a3\u5c31\u8bf7\u5404\u4f4d\u670b\u53cb\u7ee7\u7eed\u770b\u4e0b\u53bb\u5427~\u5e0c\u671b\u80fd\u771f\u6b63\u5e2e\u5230\u4f60\u4eec\uff0c\u8c22\u8c22\uff01<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.17golang.com\/uploads\/20241201\/1733056419674c57a3b3610.jpg\" class=\"aligncenter\" title=\"Flutter \u5982\u4f55\u4f7f\u7528 encrypt \u5e93\u5b9e\u73b0 AES \u52a0\u5bc6\uff1f\u63d2\u56fe\" alt=\"Flutter \u5982\u4f55\u4f7f\u7528 encrypt \u5e93\u5b9e\u73b0 AES \u52a0\u5bc6\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong>flutter \u4e2d\u5982\u4f55\u5728\u4ee3\u7801\u4e2d\u5b9e\u73b0\u7c7b\u4f3c javascript \u65b9\u5f0f\u7684 aes \u52a0\u5bc6\uff1f<\/strong><\/p>\n<p>javascript \u4ee3\u7801\u4e2d\u901a\u8fc7 cryptojs \u5e93\u5b9e\u73b0\u4e86 aes \u52a0\u5bc6\u3002\u90a3\u4e48\uff0c\u5982\u4f55\u5c06\u8fd9\u79cd\u52a0\u5bc6\u65b9\u5f0f\u5e94\u7528\u5230 flutter \u9879\u76ee\u4e2d\u5462\uff1f<\/p>\n<p>\u4e3a\u4e86\u89e3\u51b3\u8fd9\u4e2a\u95ee\u9898\uff0c\u53ef\u4ee5\u4f7f\u7528 dart \u4e2d\u7684 encrypt \u5e93\u3002\u6b64\u5e93\u63d0\u4f9b\u4e86\u7528\u4e8e aes \u52a0\u5bc6\u7684\u7c7b\u548c\u65b9\u6cd5\u3002<\/p>\n<p>\u5177\u4f53\u5b9e\u73b0\u4ee3\u7801\u5982\u4e0b\uff1a<\/p>\n<pre>import 'package:encrypt\/encrypt.dart';\n\nstatic String encryptAes(\n    String plainText,\n  ) {\n    const key = 'ihaierForTodoKey';\n    const iv = 'ihaierForTodo_Iv';\n    final _key = encrypt.Key.fromUtf8(key);\n    final _iv = encrypt.IV.fromUtf8(iv);\n    final encrypter = encrypt.Encrypter(encrypt.AES(_key, mode: encrypt.AESMode.cbc));\n\n    final encrypted = encrypter.encrypt(plainText, iv: _iv);\n\n    return encrypted.base64;\n  }<\/pre>\n<p>\u4eca\u5929\u5173\u4e8e\u300aFlutter \u5982\u4f55\u4f7f\u7528 encrypt \u5e93\u5b9e\u73b0 AES \u52a0\u5bc6\uff1f\u300b\u7684\u5185\u5bb9\u5c31\u4ecb\u7ecd\u5230\u8fd9\u91cc\u4e86\uff0c\u662f\u4e0d\u662f\u5b66\u8d77\u6765\u4e00\u76ee\u4e86\u7136\uff01\u60f3\u8981\u4e86\u89e3\u66f4\u591a\u5173\u4e8e\u7684\u5185\u5bb9\u8bf7\u5173\u6ce8\u7c73\u4e91\u516c\u4f17\u53f7\uff01<\/p>\n<dl>\n<dt><\/dt>\n<dd>\n   \u5168\u9762\u89e3\u6790USB 3.0\uff1a\u4f18\u70b9\u3001\u7279\u70b9\u53ca\u5e94\u7528\u573a\u666f\n <\/dd>\n<\/dl>\n","protected":false},"excerpt":{"rendered":"<p>Flutter \u5982\u4f55\u4f7f\u7528 encrypt \u5e93\u5b9e\u73b0 AES \u52a0\u5bc6\uff1f \u5927\u5bb6\u597d\uff0c\u4eca\u5929\u672c\u4eba\u7ed9\u5927\u5bb6\u5e26\u6765\u6587\u7ae0\u300aFlutter \u5982\u4f55\u4f7f\u7528 encrypt \u5e93\u5b9e\u73b0 AES \u52a0\u5bc6\uff1f\u300b\uff0c\u6587\u4e2d\u5185\u5bb9\u4e3b\u8981\u6d89\u53ca\u5230\uff0c\u5982\u679c\u4f60\u5bf9\u6587\u7ae0\u65b9\u9762\u7684\u77e5\u8bc6\u70b9\u611f\u5174\u8da3\uff0c\u90a3\u5c31\u8bf7\u5404\u4f4d\u670b\u53cb\u7ee7\u7eed\u770b\u4e0b\u53bb\u5427~\u5e0c\u671b\u80fd\u771f\u6b63\u5e2e\u5230\u4f60\u4eec\uff0c\u8c22\u8c22\uff01 flutter \u4e2d\u5982\u4f55\u5728\u4ee3\u7801\u4e2d\u5b9e\u73b0\u7c7b\u4f3c javascript \u65b9\u5f0f\u7684 aes \u52a0\u5bc6\uff1f javascript \u4ee3\u7801\u4e2d\u901a\u8fc7 cryptojs \u5e93\u5b9e\u73b0\u4e86 aes \u52a0\u5bc6\u3002\u90a3\u4e48\uff0c\u5982\u4f55\u5c06\u8fd9\u79cd\u52a0\u5bc6\u65b9\u5f0f\u5e94\u7528\u5230 flutter \u9879\u76ee\u4e2d\u5462\uff1f \u4e3a\u4e86\u89e3\u51b3\u8fd9\u4e2a\u95ee\u9898\uff0c\u53ef\u4ee5\u4f7f\u7528 dart \u4e2d\u7684 encrypt \u5e93\u3002\u6b64\u5e93\u63d0\u4f9b\u4e86\u7528\u4e8e aes \u52a0\u5bc6\u7684\u7c7b\u548c\u65b9\u6cd5\u3002 \u5177\u4f53\u5b9e\u73b0\u4ee3\u7801\u5982\u4e0b\uff1a import &#8216;package:encrypt\/encrypt.dart&#8217;; static String encryptAes( String plainText, ) { const key = &#8216;ihaierForTodoKey&#8217;; const iv = &#8216;ihaierForTodo_Iv&#8217;; final _key = encrypt.Key.fromUtf8(key); [&hellip;]<\/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-53545","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/53545","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=53545"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/53545\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=53545"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=53545"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=53545"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}