mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-07-21 15:09:48 +08:00
add XXTEA
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package cn.hutool.crypto.test.symmetric;
|
||||
|
||||
import cn.hutool.crypto.symmetric.SymmetricCrypto;
|
||||
import cn.hutool.crypto.symmetric.XXTEA;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
@@ -10,7 +11,7 @@ import org.junit.Test;
|
||||
public class TEATest {
|
||||
|
||||
@Test
|
||||
public void teaTest(){
|
||||
public void teaTest() {
|
||||
String data = "测试的加密数据 by Hutool";
|
||||
|
||||
// 密钥必须为128bit
|
||||
@@ -24,7 +25,7 @@ public class TEATest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void xteaTest(){
|
||||
public void xteaTest() {
|
||||
String data = "测试的加密数据 by Hutool";
|
||||
|
||||
// 密钥必须为128bit
|
||||
@@ -36,4 +37,18 @@ public class TEATest {
|
||||
|
||||
Assert.assertEquals(data, decryptStr);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void xxteaTest() {
|
||||
String data = "测试的加密数据 by Hutool";
|
||||
|
||||
// 密钥必须为128bit
|
||||
final XXTEA tea = new XXTEA("MyPassword123456".getBytes());
|
||||
final byte[] encrypt = tea.encrypt(data);
|
||||
|
||||
// 解密
|
||||
final String decryptStr = tea.decryptStr(encrypt);
|
||||
|
||||
Assert.assertEquals(data, decryptStr);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user