public class CipherWrapper extends Object
Constructor and Description |
---|
CipherWrapper(Cipher cipher)
构造
|
CipherWrapper(String algorithm)
构造
|
Modifier and Type | Method and Description |
---|---|
Cipher |
getCipher()
获取被包装的
Cipher |
AlgorithmParameterSpec |
getParams()
获取
AlgorithmParameterSpec 在某些算法中,需要特别的参数,例如在ECIES中,此处为IESParameterSpec |
CipherWrapper |
initMode(int mode,
Key key)
初始化
Cipher 为加密或者解密模式 |
CipherWrapper |
setParams(AlgorithmParameterSpec params)
设置
AlgorithmParameterSpec ,通常用于加盐或偏移向量 |
CipherWrapper |
setRandom(SecureRandom random)
设置随机数生成器,可自定义随机数种子
|
public CipherWrapper(String algorithm)
algorithm
- 算法名称public AlgorithmParameterSpec getParams()
AlgorithmParameterSpec
AlgorithmParameterSpec
public CipherWrapper setParams(AlgorithmParameterSpec params)
AlgorithmParameterSpec
,通常用于加盐或偏移向量params
- AlgorithmParameterSpec
public CipherWrapper setRandom(SecureRandom random)
random
- 随机数生成器,可自定义随机数种子public CipherWrapper initMode(int mode, Key key) throws InvalidKeyException, InvalidAlgorithmParameterException
Cipher
为加密或者解密模式mode
- 模式,见Cipher.ENCRYPT_MODE
或 Cipher.DECRYPT_MODE
key
- 密钥InvalidKeyException
- 无效keyInvalidAlgorithmParameterException
- 无效算法Copyright © 2024. All rights reserved.