Android 自带Base64加密解密

Android项目引用不到以下两个java类

import sun.misc.BASE64Decoder;
import sun.misc.BASE64Encoder;

Android有自己的base64类

import android.util.Base64
//import android.util.Base64;  
String str = "Hello!";  
//base64编码  
//String strBase64 = new String(Base64.encode(str.getBytes(), Base64.DEFAULT));  
String strBase64 = Base64.encodeToString(str.getBytes(), Base64.DEFAULT);  
//base64解码  
String str2 = new String(Base64.decode(strBase64.getBytes(), Base64.DEFAULT));  
原文地址:https://www.cnblogs.com/zhujiabin/p/7877777.html