All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.gitee.huanminabc.utils_common.encryption.base64.Base64Utils Maven / Gradle / Ivy

There is a newer version: 1.0.5-RELEASE
Show newest version
package com.gitee.huanminabc.utils_common.encryption.base64;

import java.util.Base64;
import java.util.Base64.Encoder;

/**
 * 

Base64编码解码。

* * @author zxc * 2022/2/17 */ public class Base64Utils { /** * 使用base64编码字符串 * * @param message {@link String}待编码的字符串 * @return {@link String}编码后字符串 */ public static String encode(String message) { Encoder encoder = Base64.getEncoder(); return encoder.encodeToString(message.getBytes()); } /** * 解码base64字符串 * * @param encodeString {@link String}编码之后的字符串 * @return {@link String}解码后的字符串 */ public static String decode(String encodeString) { Base64.Decoder decoder = Base64.getDecoder(); byte[] decode = decoder.decode(encodeString); return new String(decode); } /** * 使用base64编码 * * @param message {@link byte[]}待编码的字符串 * @return {@link byte[]}编码后字符串 */ public static byte[] encode(byte[] message) { Encoder encoder = Base64.getEncoder(); return encoder.encode(message); } /** * 解码base64 * @param encodeString {@link byte[]}编码之后的字符串 * @return {@link byte[]}解码后的字符串 */ public static byte[] decode(byte[] encodeString) { Base64.Decoder decoder = Base64.getDecoder(); return decoder.decode(encodeString); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy