mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-07-21 15:09:48 +08:00
@@ -30,6 +30,9 @@ public class Base64 {
|
|||||||
* @return 编码后的bytes
|
* @return 编码后的bytes
|
||||||
*/
|
*/
|
||||||
public static byte[] encode(byte[] arr, boolean lineSep) {
|
public static byte[] encode(byte[] arr, boolean lineSep) {
|
||||||
|
if (arr == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
return lineSep ?
|
return lineSep ?
|
||||||
java.util.Base64.getMimeEncoder().encode(arr) :
|
java.util.Base64.getMimeEncoder().encode(arr) :
|
||||||
java.util.Base64.getEncoder().encode(arr);
|
java.util.Base64.getEncoder().encode(arr);
|
||||||
@@ -137,6 +140,9 @@ public class Base64 {
|
|||||||
* @return 被加密后的字符串
|
* @return 被加密后的字符串
|
||||||
*/
|
*/
|
||||||
public static String encode(byte[] source) {
|
public static String encode(byte[] source) {
|
||||||
|
if (source == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
return java.util.Base64.getEncoder().encodeToString(source);
|
return java.util.Base64.getEncoder().encodeToString(source);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -148,6 +154,9 @@ public class Base64 {
|
|||||||
* @since 5.5.2
|
* @since 5.5.2
|
||||||
*/
|
*/
|
||||||
public static String encodeWithoutPadding(byte[] source) {
|
public static String encodeWithoutPadding(byte[] source) {
|
||||||
|
if (source == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
return java.util.Base64.getEncoder().withoutPadding().encodeToString(source);
|
return java.util.Base64.getEncoder().withoutPadding().encodeToString(source);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -159,6 +168,9 @@ public class Base64 {
|
|||||||
* @since 3.0.6
|
* @since 3.0.6
|
||||||
*/
|
*/
|
||||||
public static String encodeUrlSafe(byte[] source) {
|
public static String encodeUrlSafe(byte[] source) {
|
||||||
|
if (source == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
return java.util.Base64.getUrlEncoder().withoutPadding().encodeToString(source);
|
return java.util.Base64.getUrlEncoder().withoutPadding().encodeToString(source);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user