[测评系统]--测评系统核心代码库
linzhijie
2023-04-15 0183c9be7ee7c2125bdd0491a9ba406de6abc621
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
35
36
37
38
39
40
package com.ots.common.utils;
 
import java.util.Base64;
 
/**
 * @description: base64 加解密
 * @author: zhijie
 * @create: 2022-01-03 17:27
 **/
public class Base64Utils {
 
    /**
     * 加密
     * @param data
     * @return
     */
    public static String encode(String data){
        Base64.Encoder encoder = Base64.getEncoder();
        byte[] b = encoder.encode(data.getBytes());
        b = encoder.encode(b);
        b = encoder.encode(b);
        return new String(b);
    }
 
    public static String decode(String data){
        Base64.Decoder decoder = Base64.getDecoder();
        byte[] b = decoder.decode(data.getBytes());
        b = decoder.decode(b);
        b = decoder.decode(b);
        return new String(b);
    }
 
    public static void main(String[] args) {
        String str = Base64Utils.encode("411");
        String str1 = Base64Utils.decode(str);
        System.out.println(str);
        System.out.println(str1);
    }
 
}