xuhy
2025-01-09 712f70b2936079a131ecb1e63c6d337171618cad
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
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);
    }
 
}