[*] 日常优化
This commit is contained in:
@@ -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 密钥
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user