fix base64 NPE verification

This commit is contained in:
bwcx_jzy 2023-09-12 17:23:54 +08:00
parent 4771078cf4
commit e341bd5ec2
No known key found for this signature in database
GPG Key ID: E187D6E9DDDE8C53

View File

@ -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);
}