mirror of
https://gitee.com/dromara/hutool.git
synced 2025-04-05 17:37:59 +08:00
fix base64 NPE verification
This commit is contained in:
parent
4771078cf4
commit
e341bd5ec2
@ -30,6 +30,9 @@ public class Base64 {
|
||||
* @return 编码后的bytes
|
||||
*/
|
||||
public static byte[] encode(byte[] arr, boolean lineSep) {
|
||||
if (arr == null) {
|
||||
return null;
|
||||
}
|
||||
return lineSep ?
|
||||
java.util.Base64.getMimeEncoder().encode(arr) :
|
||||
java.util.Base64.getEncoder().encode(arr);
|
||||
@ -137,6 +140,9 @@ public class Base64 {
|
||||
* @return 被加密后的字符串
|
||||
*/
|
||||
public static String encode(byte[] source) {
|
||||
if (source == null) {
|
||||
return null;
|
||||
}
|
||||
return java.util.Base64.getEncoder().encodeToString(source);
|
||||
}
|
||||
|
||||
@ -148,6 +154,9 @@ public class Base64 {
|
||||
* @since 5.5.2
|
||||
*/
|
||||
public static String encodeWithoutPadding(byte[] source) {
|
||||
if (source == null) {
|
||||
return null;
|
||||
}
|
||||
return java.util.Base64.getEncoder().withoutPadding().encodeToString(source);
|
||||
}
|
||||
|
||||
@ -159,6 +168,9 @@ public class Base64 {
|
||||
* @since 3.0.6
|
||||
*/
|
||||
public static String encodeUrlSafe(byte[] source) {
|
||||
if (source == null) {
|
||||
return null;
|
||||
}
|
||||
return java.util.Base64.getUrlEncoder().withoutPadding().encodeToString(source);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user