ApiTest.java
1.12 KB
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
41
package com.topdraw.dockingapi;
import com.topdraw.dockingapi.util.DecryptUtils;
import lombok.SneakyThrows;
import org.junit.jupiter.api.Test;
import javax.crypto.Cipher;
import javax.crypto.spec.SecretKeySpec;
import java.nio.charset.StandardCharsets;
import java.security.Security;
/**
* @author wenxin
* @version 1.0
* @date 2024/5/23 下午4:40
*/
public class ApiTest {
// 将字节转换为十六进制字符串
public static String bytesToHex(byte[] bytes) {
StringBuilder hexString = new StringBuilder();
for (byte b : bytes) {
String hex = Integer.toHexString(0xff & b);
if (hex.length() == 1) hexString.append('0');
hexString.append(hex);
}
return hexString.toString();
}
@SneakyThrows
@Test
public void testEncode(){
String text = "{\"phoneNum\":\"13627618074\"}";
System.out.println(DecryptUtils.encode("wmsj2021", text));
String tt="U0ELEkckqqxwzutWXbySgJmGbWQovd9n7UZSWqYt5HpXOxOsQwTnrjGp7geAhD/Mp9Jy3okXkRtt0cuFDdlMjPDgsBK3SMu0";
System.out.println(DecryptUtils.decode("wmsj2021", tt));
}
}