mirror of
https://github.com/qaiu/netdisk-fast-download.git
synced 2025-12-17 21:03:03 +00:00
- 加入小飞机盘直链解析
- 优化代码
This commit is contained in:
57
web-service/src/test/java/cn/qaiu/web/test/TestAESUtil.java
Normal file
57
web-service/src/test/java/cn/qaiu/web/test/TestAESUtil.java
Normal file
@@ -0,0 +1,57 @@
|
||||
package cn.qaiu.web.test;
|
||||
|
||||
import cn.qaiu.lz.common.util.AESUtils;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import javax.crypto.BadPaddingException;
|
||||
import javax.crypto.IllegalBlockSizeException;
|
||||
import javax.crypto.NoSuchPaddingException;
|
||||
import java.security.InvalidKeyException;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.util.HexFormat;
|
||||
|
||||
public class TestAESUtil {
|
||||
|
||||
// 1686215935703
|
||||
// B4C5B9833113ACA41F16AABADE17349C
|
||||
@Test
|
||||
public void decode() throws NoSuchPaddingException, IllegalBlockSizeException, NoSuchAlgorithmException,
|
||||
BadPaddingException, InvalidKeyException {
|
||||
String hex = AESUtils.encryptHexByAES("1686215935703", AESUtils.CIPHER_AES2);
|
||||
Assert.assertEquals("B4C5B9833113ACA41F16AABADE17349C", hex.toUpperCase());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void encode() throws IllegalBlockSizeException, NoSuchPaddingException, BadPaddingException,
|
||||
NoSuchAlgorithmException, InvalidKeyException {
|
||||
String source = AESUtils.decryptByHexAES("B4C5B9833113ACA41F16AABADE17349C", AESUtils.CIPHER_AES2);
|
||||
Assert.assertEquals("1686215935703", source);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void toHex() {
|
||||
byte[] d234EF67A1s = HexFormat.of().parseHex("D234EF67A1");
|
||||
Assert.assertArrayEquals(new byte[]{(byte) 0xd2, (byte) 0x34, (byte) 0xef, (byte) 0x67, (byte) 0xa1},
|
||||
d234EF67A1s);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void base64AES() throws NoSuchAlgorithmException {
|
||||
System.out.println(HexFormat.of().formatHex(AESUtils.createKeyString(AESUtils.KEY_SIZE_128_LENGTH).getEncoded()));
|
||||
System.out.println(HexFormat.of().formatHex(AESUtils.createKeyString(AESUtils.KEY_SIZE_192_LENGTH).getEncoded()));
|
||||
System.out.println(HexFormat.of().formatHex(AESUtils.createKeyString(AESUtils.KEY_SIZE_256_LENGTH).getEncoded()));
|
||||
|
||||
// TODO Base64-AES
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIdDecode() {
|
||||
Assert.assertEquals(146731, AESUtils.idEncrypt("7jy0zlv"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTs() {
|
||||
System.out.println(System.currentTimeMillis());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user