kimi
2021-02-18 0ac056bb5b4c567293482286c80a1b83a467cd33
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
package chat.user;
 
import chat.security.DES;
 
public class Token {
 
    private static String KEY = "testim";
    private String value;
    private String fullValue;
    
    public Token(String userId, String secret) throws Exception {
        generateValue(userId, secret);
    }
 
    private void generateValue(String userId, String secret) throws Exception {
        String text = KEY + "|" + (System.currentTimeMillis()) + "|" + userId;
        value = DES.encryptDES(text);
        fullValue = value + "|" + secret + "|" + secret;
    }
 
    public String getValue() {
        return value;
    }
    
    public byte[] getFullValue() {
        return fullValue.getBytes();
    }
 
    public static void setKey(String key) {
        KEY = key;
    }
    
}