美文网首页
Java Base64

Java Base64

作者: 还是那个没头脑 | 来源:发表于2021-10-28 18:09 被阅读0次
    public static String encode(byte[] bstr) {
        /**
         * 编码
         * @param byte[]
         * @return string
         */
        return new sun.misc.BASE64Encoder().encode(bstr);
    }

    
    public static byte[] decode(String str){
        /**
         * 解码
         * @param str
         * @return string
         */
        byte[] bt = null;
        try {
            sun.misc.BASE64Decoder decoder = new sun.misc.BASE64Decoder();
            bt = decoder.decodeBuffer(str);
        } catch (IOException e) {
            e.printStackTrace();
        }

        return bt;
    }

相关文章

网友评论

      本文标题:Java Base64

      本文链接:https://www.haomeiwen.com/subject/qtivaltx.html