windows有可直接调用的base64编码解码函数吗
答案:2 悬赏:60
解决时间 2021-11-13 09:35
- 提问者网友:小姐请专情
- 2021-11-13 06:33
windows有可直接调用的base64编码解码函数吗
最佳答案
- 二级知识专家网友:走,耍流氓去
- 2021-11-13 07:47
很简单// 将 s 进行 BASE64 编码
public static String getBASE64(String s) {
if (s == null) return null;
return (new sun.misc.BASE64Encoder()).encode( s.getBytes() );
public static String getBASE64(String s) {
if (s == null) return null;
return (new sun.misc.BASE64Encoder()).encode( s.getBytes() );
全部回答
- 1楼网友:星痕之殇
- 2021-11-13 09:06
import sun.misc.base64encoder;
import sun.misc.base64decoder;
// 将 s 进行 base64 编码
public static string getbase64(string s) {
if (s == null) return null;
return (new sun.misc.base64encoder()).encode( s.getbytes() );
}
// 将 base64 编码的字符串 s 进行解码
public static string getfrombase64(string s) {
if (s == null) return null;
base64decoder decoder = new base64decoder();
try {
byte[] b = decoder.decodebuffer(s);
return new string(b);
} catch (exception e) {
return null;
}
}
我要举报
如以上问答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯