{"id":333,"date":"2017-02-03T23:46:28","date_gmt":"2017-02-03T15:46:28","guid":{"rendered":"http:\/\/www.rainweb.site\/?p=333"},"modified":"2017-02-03T23:46:28","modified_gmt":"2017-02-03T15:46:28","slug":"java-article0014","status":"publish","type":"post","link":"http:\/\/rain1024.com\/index.php\/2017\/02\/03\/java-article0014\/","title":{"rendered":"Base64\u4e13\u9898&#8212;java\u4e2d\u4f7f\u7528Base64\u52a0\u5bc6\u89e3\u5bc6\u7684\u51fd\u6570"},"content":{"rendered":"<h4>Base\u52a0\u5bc6\u65b9\u6cd5\u5f88\u65b9\u4fbf\uff0c\u5728\u4fdd\u5b58\u4e00\u4e9b\u7279\u522b\u6570\u636e\u65f6\u53ef\u4ee5\u76f4\u63a5\u8c03\u7528\u65b9\u6cd5\u8fdb\u884c\u52a0\u5bc6\u548c\u89e3\u5bc6\u7684\u64cd\u4f5c\uff0c\u6211\u4f1a\u53d1\u4e00\u7bc7\u4e13\u95e8\u4ecb\u7ecdbase64\u539f\u7406\u7684\u6587\u7ae0\uff0c\u6709\u5174\u8da3\u7684\u53ef\u4ee5\u5148\u53bb\u67e5\u770b\u3002\u8fd8\u6709php\u548cpython\u7684\u4f7f\u7528\u4ee3\u7801\u6211\u90fd\u4f1a\u8d34\u5728\u6587\u7ae0\u6700\u540e\u3002<\/h4>\n<h5>\u4e0b\u9762\u662f\u4f7f\u7528java\u8fdb\u884cbase64\u52a0\u5bc6\u4e0e\u89e3\u5bc6\u7684\u6e90\u7801\uff0c\u4f7f\u7528\u65f6\u5728java\u9879\u76ee\u4e2d\u65b0\u5efa\u4e00\u4e2a\u7c7b\uff0c\u7136\u540e\u5c06\u4ee3\u7801\u6302\u4e0a\uff0c\u5728\u5916\u90e8\u52a0\u5bc6\u6216\u89e3\u5bc6\u76f4\u63a5\u5b9e\u4f8b\u5316\u7c7b\uff0c\u518d\u8c03\u7528\u54cd\u5e94\u51fd\u6570\u5373\u53ef\uff0c\u8bb0\u4f4f\u503c\u7684\u4f20\u9012\u4e0e\u63a5\u6536<\/h5>\n<h5>Base64\u52a0\u5bc6<\/h5>\n<pre><code>public static String encodeBase64(String cleartext) {\n\/\/ TODO Auto-generated method stub\ntry {\ncleartext = new String(Base64.encodeBase64(cleartext.getBytes(\"UTF-8\")));\n} catch (UnsupportedEncodingException e) {\n\/\/ TODO Auto-generated catch block\ne.printStackTrace();\n}\nreturn cleartext;\n}\n<\/code><\/pre>\n<h5>Base\u89e3\u5bc6<\/h5>\n<pre><code>public static String decodeBase64(String ciphertext){\ntry {\nciphertext = new String(Base64.decodeBase64(ciphertext.getBytes()),\n\"UTF-8\");\n} catch (UnsupportedEncodingException e) {\n\/\/ TODO Auto-generated catch block\ne.printStackTrace();\n}\nreturn ciphertext;\n}\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Base\u52a0\u5bc6\u65b9\u6cd5\u5f88\u65b9\u4fbf\uff0c\u5728\u4fdd\u5b58\u4e00\u4e9b\u7279\u522b\u6570\u636e\u65f6\u53ef\u4ee5\u76f4\u63a5\u8c03\u7528\u65b9\u6cd5\u8fdb\u884c\u52a0\u5bc6\u548c\u89e3\u5bc6\u7684\u64cd\u4f5c\uff0c\u6211\u4f1a\u53d1\u4e00\u7bc7\u4e13\u95e8\u4ecb\u7ecdbase6\u2026 <span class=\"read-more\"><a href=\"http:\/\/rain1024.com\/index.php\/2017\/02\/03\/java-article0014\/\">Read More &raquo;<\/a><\/span><\/p>\n","protected":false},"author":2,"featured_media":224,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"aside","meta":{"footnotes":""},"categories":[31],"tags":[38,46,85],"class_list":["post-333","post","type-post","status-publish","format-aside","has-post-thumbnail","hentry","category-java","tag-base","tag-java","tag-code","post_format-post-format-aside"],"_links":{"self":[{"href":"http:\/\/rain1024.com\/index.php\/wp-json\/wp\/v2\/posts\/333","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/rain1024.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/rain1024.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/rain1024.com\/index.php\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/rain1024.com\/index.php\/wp-json\/wp\/v2\/comments?post=333"}],"version-history":[{"count":0,"href":"http:\/\/rain1024.com\/index.php\/wp-json\/wp\/v2\/posts\/333\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/rain1024.com\/index.php\/wp-json\/wp\/v2\/media\/224"}],"wp:attachment":[{"href":"http:\/\/rain1024.com\/index.php\/wp-json\/wp\/v2\/media?parent=333"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/rain1024.com\/index.php\/wp-json\/wp\/v2\/categories?post=333"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/rain1024.com\/index.php\/wp-json\/wp\/v2\/tags?post=333"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}