当前位置:   article > 正文

Android Base64Util工具类_android base64工具类

android base64工具类

Android Base64Util 工具类

public class Base64Util {

    public static String strToBase64(String str) {
        byte[] byteStr = str.getBytes(StandardCharsets.UTF_8);
        return Base64.encodeToString(byteStr, Base64.DEFAULT);
    }

    public static String base64ToStr(String str) {
        byte[] byteStr = Base64.decode(str, Base64.DEFAULT);
        return new String(byteStr);
    }

    public static String encode(byte[] key) {
        return Base64.encodeToString(key, Base64.DEFAULT);
    }

    public static byte[] decode(String key) {
        return Base64.decode(key, Base64.DEFAULT);
    }
}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/Monodyee/article/detail/202916
推荐阅读
相关标签
  

闽ICP备14008679号