android Base64 加密解密
程序员文章站
2024-03-14 13:28:40
...
android Base64 加密解密
//加密 hello
byte[] mimeBytes = "hello".getBytes("utf-8");
str= Base64.encodeToString(mimeBytes,Base64.DEFAULT);
//结果:GVsbG8=
//解密
byte[] result= Base64.decode(contentBase.getBytes(),Base64.DEFAULT);
//结果:hello
//解密
byte[] result= Base64.decode(contentBase.getBytes(),Base64.DEFAULT);
//结果:hello
oppo特殊机型报错
Failed resolution of: Ljava/util/Base64;
//oppo特殊机型报错 可用import android.util.Base64; 上述方案
byte[] mimeBytes = content.toString().getBytes("utf-8");
byte[] mimeEncodedString = java.util.Base64.getEncoder().encode(mimeBytes);
上一篇: PHP des 3des加解密