forked from striner/javaCode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAESUtilTest.java
More file actions
34 lines (27 loc) · 1.45 KB
/
Copy pathAESUtilTest.java
File metadata and controls
34 lines (27 loc) · 1.45 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
package utils;
import common.utils.AESUtil;
import org.junit.Test;
public class AESUtilTest {
@Test
public static void main(String[] args) {
String s = "加密测试";
// 加密 默认key
System.out.println("加密前:" + s);
String encryptResultStr1 = AESUtil.encrypt(s);
System.out.println("加密后:" + encryptResultStr1);
// 解密
System.out.println("解密后:" + AESUtil.decrypt(encryptResultStr1));
AESUtil.key = "1230485203699875";
// 加密
System.out.println("加密前:" + s);
String encryptResultStr = AESUtil.encrypt(s);
System.out.println("加密后:" + encryptResultStr);
// 解密
System.out.println("解密后:" + AESUtil.decrypt(encryptResultStr));
System.out.println("---------------------------------------------");
System.out.println("加密后:" + AESUtil.encrypt("test", AESUtil.key));
System.out.println("解密后:" + AESUtil.decrypt(AESUtil.encrypt("test", AESUtil.key), AESUtil.key));
System.out.println("32位密钥加密测试:" + AESUtil.encrypt("当我们把密钥定为大于128时(即192或256)时","01234567890123450123456789012345"));
System.out.println("32位密钥解密测试:" + AESUtil.decrypt(AESUtil.encrypt("当我们把密钥定为大于128时(即192或256)时", "01234567890123450123456789012345"), "01234567890123450123456789012345"));
}
}