package com.stylefeng.guns.modular.account.util;
|
|
import java.nio.charset.StandardCharsets;
|
import java.util.Base64;
|
|
/**
|
* @author xiaochen
|
* @Description Base64 加解密工具
|
* @date 2023/4/4 16:10
|
*/
|
public class Base64Util {
|
|
final static Base64.Encoder encoder = Base64.getEncoder();
|
final static Base64.Decoder decoder = Base64.getDecoder();
|
|
/**
|
* 加密
|
* @param text
|
* @return
|
*/
|
public static String encode(String text) {
|
return encoder.encodeToString(text.getBytes(StandardCharsets.UTF_8));
|
}
|
|
/**
|
* 解密
|
* @param encodedText
|
* @return
|
*/
|
public static String decode(String encodedText) {
|
return new String(decoder.decode(encodedText), StandardCharsets.UTF_8);
|
}
|
|
}
|