0
点赞
收藏
分享

微信扫一扫

Apache的Base64位编码

杨沐涵 2023-03-21 阅读 64

package com.geosun.core.utils;


import org.apache.commons.codec.binary.Base64;


public class Base64Utils {

/**

* * BASE64解码

*

* @param base64

* @return

*/

public static byte[] decodeBASE64(String base64) {

return Base64.decodeBase64(base64.getBytes());

}


/**

* * BASE64解码

*

* @param base64

* @param changeCase

* @return

*/

public static String decodeBASE64AsString(String base64) {

byte[] bytes = decodeBASE64(base64);

return new String(bytes);

}


/**

* * BASE64编码

*

* @param bytes

* @return

*/

public static String encodeBASE64(byte[] bytes) {

byte[] base64Bytes = Base64.encodeBase64(bytes);

return new String(base64Bytes);

}


/**

* * BASE64编码

*

* @param str

* @return

*/

public static String encodeBASE64(String str) {

return encodeBASE64(str.getBytes());

}

}

举报

相关推荐

0 条评论