首页 > 编程知识 正文

BASE64Decoder,base64转换器

时间:2023-05-06 19:45:33 阅读:48453 作者:4701

在项目过程中,对某个字符串进行BASE64加密,遍布百度找到、记录解决方案,加深印象。

要使用的jar包: import sun.misc.base64解码器;

//S编码为BASE64

publicstaticstringgetbase 64 (strings ) {

if(s==null ) )。

返回空值;

return (news un.misc.base64 encoder () ).encode (s.getbytes ) );

}

对用BASE64编码的字符串s进行解码

publicstaticstringgetfrombase 64 (strings )。

if(s==null )返回空值;

base64解码器解码器=new base64解码器(;

try {

byte[]b=decoder.decodebuffer(s;

返回新字符串(b;

}catch(exceptione ) {

返回空值;

}

}

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。