mirror of
https://gitee.com/dromara/hutool.git
synced 2025-04-05 17:37:59 +08:00
add test
This commit is contained in:
parent
7f2f134068
commit
3c20afbf18
@ -0,0 +1,23 @@
|
||||
package org.dromara.hutool.crypto.symmetric;
|
||||
|
||||
import org.dromara.hutool.crypto.Mode;
|
||||
import org.dromara.hutool.crypto.SecureUtil;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/**
|
||||
* https://tool.hiofd.com/sm4-encrypt-online/
|
||||
*/
|
||||
public class Issue3871Test {
|
||||
@Test
|
||||
void sm4Test(){
|
||||
final String data = "{\"mobile\":\"13333333333\"}";
|
||||
final byte[] key = SecureUtil.decode("Q5v/nsxmaCdFiltxIz+TCQ==");
|
||||
final byte[] iv = SecureUtil.decode("Dz15D//HqTvavbckOWgKiw==");
|
||||
|
||||
final SM4 sm4 = new SM4(Mode.CBC.name(), "PKCS5Padding", key, iv);
|
||||
final String encryptBase64 = sm4.encryptBase64(data);
|
||||
Assertions.assertEquals("T6J7tGSQXam0BPauZIamqd5lJ/+I6q42vlziP3HBtT8=", encryptBase64);
|
||||
Assertions.assertEquals(data, sm4.decryptStr(encryptBase64));
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user