惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Google DeepMind News
Google DeepMind News
罗磊的独立博客
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
Last Week in AI
Last Week in AI
云风的 BLOG
云风的 BLOG
T
The Blog of Author Tim Ferriss
Y
Y Combinator Blog
A
About on SuperTechFans
WordPress大学
WordPress大学
B
Blog
Martin Fowler
Martin Fowler
Jina AI
Jina AI
I
InfoQ
P
Proofpoint News Feed
小众软件
小众软件
S
SegmentFault 最新的问题
V
V2EX
B
Blog RSS Feed
量子位
大猫的无限游戏
大猫的无限游戏
aimingoo的专栏
aimingoo的专栏
博客园 - 三生石上(FineUI控件)
MongoDB | Blog
MongoDB | Blog
美团技术团队

博客园 - 笑清风

IDEA 2025.2 Maven 在windows下编译打包中文乱码解决方案 milvus相关概念 milvus介绍 Mockito之doThrow 关于行为面试法——STAR JVM 内存分析工具 MAT 的深度讲解与实践——入门篇《转》 linux top 中的time+ notepad++删除包含指定字符串的行(正则) JVM指令码表 Hadoop家族成员概述 轻松把玩HttpClient之封装HttpClient工具类 SOAP1.1&SOAP1.2 画图解释SQL联合语句 Elasticsearch相关资源 SQL Server 数据类型映射 SQL Server类型的对应关系 Rethrowing exceptions and preserving the full call stack trace The CLR's Thread Pool .Net下获取程序路径的方法
Base64
笑清风 · 2019-09-20 · via 博客园 - 笑清风

从JDK 1.8开始,就提供了java.util.Base64.Decoder和java.util.Base64.Encoder的JDK公共API,可代替sun.misc.BASE64Decoder和sun.misc.BASE64Encoder的JDK内部API

 /**
     * BASE64 加密
     * 
     * @param data
     *            要加密的数据
     * @return 加密后的字符串
     */
    public static String encryptBASE64(byte[] data) {
        Encoder encoder = Base64.getEncoder();
        String encode = encoder.encodeToString(data);
        return encode;
    }
    /**
     * BASE64  解密
     * 
     * @param data
     *            要解密的字符串
     * @return 解密后的byte[]
     * @throws Exception
     */
    public static byte[] decryptBASE64(String data) throws Exception {
        Decoder decoder = Base64.getDecoder();
        byte[] buffer = decoder.decode(data);
        return buffer;
    }