base64 编码、解码util
来源:互联网 发布:linux deploy下载 编辑:程序博客网 时间:2024/05/21 06:58
import sun.misc.BASE64Encoder;import java.io.UnsupportedEncodingException;public class Base64Util { /** * * 将 s 进行 BASE64 编码 * base64 编码、解码util * 解码 编码字符格式必须一致 * @return String */ public static String encode(String s) { if (s == null) return null; String res = ""; try { res = new sun.misc.BASE64Encoder().encode(s.getBytes("utf-8")); } catch (UnsupportedEncodingException e) { // TODO Auto-generated catch block e.printStackTrace(); } return res; } /** * 将 BASE64 编码的字符串 s 进行解码 * * @return String */ public static String decode(String s) { if (s == null) return null; BASE64Decoder decoder = new BASE64Decoder(); try { byte[] b = decoder.decodeBuffer(s); return new String(b,"utf-8"); } catch (Exception e) { return null; } } /** * * @return void */ public static void main(String[] args) { System.out.println(Base64Util.encode("测试数据")); System.out.println(Base64Util.decode("uf65/g==")); }}
阅读全文
0 0
- base64 编码、解码util
- base64编码和解码
- base64编码/解码
- BASE64编码和解码
- Base64编码解码
- Base64编码与解码
- Base64编码及解码
- BASE64编码与解码
- BASE64编码与解码
- Base64编码/解码模块
- base64编码/解码
- Base64编码/解码模块
- base64编码解码函数
- BASE64编码解码算法
- base64编码/解码 javascript
- base64编码/解码 javascript
- base64编码和解码
- Base64编码解码类
- 用Kubernetes部署超级账本Fabric的区块链即服务
- 小米两款千元机同时“挤”iphone,谁将是赢家呢?
- MarkDown使用技巧整理
- 小明的难题
- string CString char*之间的转换
- base64 编码、解码util
- 一分钟了解"英语表达:为了什么目的"
- 修改迁移eclipse中maven默认仓库路径
- 一篇文章,教你学会Git
- 第五十篇: JAVA加密解密之数字证书
- poj 1661 左右分情况 DP
- 进程,线程区别简介
- Android源码编译jar包BUILD_JAVA_LIBRARY 与BUILD_STATIC_JAVA_LIBRARY的区别
- linux下安装phpredis