Package org.aoju.bus.crypto
Class Ciphers
java.lang.Object
org.aoju.bus.crypto.Ciphers
Cipher包装类,提供初始化模式等额外方法
包装之后可提供自定义或默认的:
- Since:
- Java 17+
- Author:
- Kimi Liu
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription获取被包装的Cipher获取AlgorithmParameterSpec在某些算法中,需要特别的参数,例如在ECIES中,此处为IESParameterSpec初始化Cipher为加密或者解密模式setParams(AlgorithmParameterSpec params) 设置AlgorithmParameterSpec,通常用于加盐或偏移向量setRandom(SecureRandom random) 设置随机数生成器,可自定义随机数种子
-
Constructor Details
-
Ciphers
构造- Parameters:
algorithm- 算法名称
-
Ciphers
构造- Parameters:
cipher-Cipher
-
-
Method Details
-
getParams
获取AlgorithmParameterSpec在某些算法中,需要特别的参数,例如在ECIES中,此处为IESParameterSpec- Returns:
AlgorithmParameterSpec
-
setParams
设置AlgorithmParameterSpec,通常用于加盐或偏移向量- Parameters:
params-AlgorithmParameterSpec- Returns:
- this
-
setRandom
设置随机数生成器,可自定义随机数种子- Parameters:
random- 随机数生成器,可自定义随机数种子- Returns:
- this
-
getCipher
获取被包装的Cipher- Returns:
Cipher
-
initMode
public Ciphers initMode(int mode, Key key) throws InvalidKeyException, InvalidAlgorithmParameterException 初始化Cipher为加密或者解密模式- Parameters:
mode- 模式,见Cipher.ENCRYPT_MODE或Cipher.DECRYPT_MODEkey- 密钥- Returns:
- this
- Throws:
InvalidKeyException- 无效keyInvalidAlgorithmParameterException- 无效算法
-