转码
String转码byte数组
public static byte[] encodeStringForByte(String source) {
return source == null ? new byte[]{} : Base64.encodeBase64(source.getBytes());
}
byte数组转码byte数组
public static byte[] encodeStringForByte(byte[] source) {
return source == null ? new byte[]{} : Base64.encodeBase64(source);
}
string转码string
public static String encodeStringForString(String source) {
return source == null ? "" : new String(Base64.encodeBase64(source.getBytes()));
}
byte数组转码string
public static String encodeByteForString(byte[] source) {
return source == null ? "" : new String(Base64.encodeBase64(source));
}
解码
string解码byte数组
public static byte[] decodeStringForByte(String source) {
return source == null ? new byte[]{} : Base64.decodeBase64(source.getBytes());
}
byte数组解码byte数组
public static byte[] decodeByteForByte(byte[] source) {
return source == null ? new byte[]{} : Base64.decodeBase64(source);
}
string解码string
public static String decodeStringForString(String source) {
return source == null ? "" : new String(Base64.decodeBase64(source.getBytes()));
}
byte数组解码string
public static String decodeByteForString(byte[] source) {
return source == null ? "" : new String(Base64.decodeBase64(source));
}
>>>源码下载链接>>>