Base64 Java org.apache.commons.codec.binary.Base64
2016-03-17 15:32
531 查看
Base64组成由 26个区分大小写字母 + 10个数字 + 一个加号 和 一个/
需要引包 import org.apache.commons.codec.binary.Base64;
apacheBase64包
package com.base64; import java.io.UnsupportedEncodingException; import org.apache.commons.codec.binary.Base64; public class Base64_ { public static String base64encode(String message) { try { byte[] encodeBase64 = Base64.encodeBase64(message.getBytes("UTF-8")); System.out.println("Result:" + new String(encodeBase64)); return new String(encodeBase64); } catch (UnsupportedEncodingException e) { throw new RuntimeException(); } } public static String base64decode(String message) { byte[] encodeBase64 = Base64.decodeBase64(message); System.out.println("Result:" + new String(encodeBase64)); return new String(encodeBase64); } }
<pre name="code" class="java">package com.base64; public class Base64Test { public static void main(String[] args) { String str = "Hello World"; String str2 = Base64_.base64encode(str); System.out.println(str2); String str1 = Base64_.base64decode(str2); System.out.println(str1); } }
需要引包 import org.apache.commons.codec.binary.Base64;
apacheBase64包
相关文章推荐
- linux下装php5+mysql5+apache
- apache spark 结合 elasticsearch
- Kafka Manager - 一个管理 Apache Kafka 的工具
- ERROR org.apache.hadoop.yarn.server.resourcemanager.ResourceManager: RECEIVED SIGNAL 15: SIGTERM
- apache kafka监控系列-KafkaOffsetMonitor
- Apache服务器配置项和虚拟机配置
- Apache Lucene 5.x 集成中文分词库 IKAnalyzer
- 在本机部署Apache服务器
- 修改服务器Apache-Coyote/1.1标识为自定义内容
- 【手把手教你全文检索】Apache Lucene初探
- Apache 安装笔记
- Apache服务器 域名解析和绑定
- 本地下载的软件包制作成本地repo源并使用apache发布
- jmeter与apache测试网站并发
- apache基金会开源项目简介
- Apache Arrow:一个跨平台的内存数据交换格式
- apache2.2下编译安装php5.6
- Apache+php 环境配置
- apache服务器URL访问管理
- apache 启用 gzip压缩