ApiTest.java 1.12 KB
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));
    }
}