[*] 日常优化

This commit is contained in:
acgist
2023-08-17 07:44:43 +08:00
parent 77e244a512
commit 4d977ee74c
3 changed files with 27 additions and 2 deletions

View File

@@ -20,12 +20,14 @@ import lombok.extern.slf4j.Slf4j;
* @author acgist
*/
@Slf4j
public class CipherUtils {
public final class CipherUtils {
private CipherUtils() {
}
/**
* 创建加密工具
*
* @param mode 模式
* @param encrypt 算法
* @param secret 密钥

View File

@@ -0,0 +1,22 @@
package com.acgist.taoyao.signal.utils;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNull;
import javax.crypto.Cipher;
import org.junit.jupiter.api.Test;
import com.acgist.taoyao.boot.config.SocketProperties.Encrypt;
public class CipherUtilsTest {
@Test
public void testBuildCipher() {
final String secret = "2SPWy+TF1zM=".strip();
assertNull(CipherUtils.buildCipher(Cipher.ENCRYPT_MODE, Encrypt.PLAINTEXT, secret));
assertNull(CipherUtils.buildCipher(Cipher.ENCRYPT_MODE, Encrypt.DES, null));
assertNotNull(CipherUtils.buildCipher(Cipher.ENCRYPT_MODE, Encrypt.DES, secret));
}
}