| Modifier and Type | Class and Description |
|---|---|
static class |
JceCipher.JceParameters
JCE的
AlgorithmParameterSpec 参数包装 |
Cipher.Parametersraw| Constructor and Description |
|---|
JceCipher(Cipher cipher)
构造
|
JceCipher(String algorithm)
构造
|
| Modifier and Type | Method and Description |
|---|---|
int |
doFinal(byte[] out,
int outOff)
处理最后一块数据
当 Cipher.process(byte[], int, int, byte[], int)处理完数据后非完整块数据,此方法用于处理块中剩余的bytes如加密数据要求128bit,即16byes的整数,单数处理数据后为15bytes,此时根据padding方式不同,可填充剩余1byte为指定值(如填充0) 当对数据进行分段加密时,需要首先多次执行process方法,在最后一块数据处理完后执行此方法。 |
String |
getAlgorithmName()
获取算法名称
|
int |
getBlockSize()
获取块大小,当为Stream方式加密时返回0
|
byte[] |
getIV()
返回新缓冲区中的初始化向量(IV)
这在创建随机IV的情况下,或在基于密码的加密或解密的上下文中是有用的,其中IV是从用户提供的密码导出的。 |
int |
getOutputSize(int len)
返回输出缓冲区为了保存下一个update或doFinal操作的结果所需的长度(以字节为单位)
下一个update或doFinal调用的实际输出长度可能小于此方法返回的长度。 |
void |
init(CipherMode mode,
Cipher.Parameters parameters)
初始化模式和参数
|
void |
init(int mode,
JceCipher.JceParameters jceParameters)
执行初始化参数操作
|
byte[] |
process(byte[] in,
int inOff,
int len)
继续多部分加密或解密操作(取决于此密码的初始化方式),处理另一个数据部分。
|
int |
process(byte[] in,
int inOff,
int len,
byte[] out)
继续多部分加密或解密操作(取决于此密码的初始化方式),处理另一个数据部分。
|
int |
process(byte[] in,
int inOff,
int len,
byte[] out,
int outOff)
执行运算,可以是加密运算或解密运算
此方法主要处理一块数据,一块数据处理完毕后,应调用 Cipher.doFinal(byte[], int)处理padding等剩余数据。 |
byte[] |
processFinal(byte[] in)
处理数据,并返回最终结果
此方法用于完整处理一块数据并返回。 |
byte[] |
processFinal(byte[] data,
int inOffset,
int inputLen)
处理数据,并返回最终结果
此方法用于完整处理一块数据并返回。 |
getRawpublic JceCipher(String algorithm)
algorithm - 算法名称public JceCipher(Cipher cipher)
cipher - Cipher,可以通过Cipher.getInstance(String)创建public String getAlgorithmName()
CiphergetAlgorithmName in interface Cipherpublic int getBlockSize()
CiphergetBlockSize in interface Cipherpublic int getOutputSize(int len)
CiphergetOutputSize in interface Cipherlen - 输入长度public byte[] getIV()
public void init(CipherMode mode, Cipher.Parameters parameters)
Cipherpublic void init(int mode,
JceCipher.JceParameters jceParameters)
throws InvalidAlgorithmParameterException,
InvalidKeyException
mode - 模式jceParameters - JceCipher.JceParametersInvalidAlgorithmParameterException - 无效算法参数InvalidKeyException - 无效keypublic byte[] process(byte[] in,
int inOff,
int len)
in - 输入缓冲区inOff - 输入开始的 input中的偏移量len - 输入长度public int process(byte[] in,
int inOff,
int len,
byte[] out)
in - 输入缓冲区inOff - 输入开始的 input中的偏移量len - 输入长度out - 结果的缓冲区public int process(byte[] in,
int inOff,
int len,
byte[] out,
int outOff)
CipherCipher.doFinal(byte[], int)处理padding等剩余数据。public int doFinal(byte[] out,
int outOff)
CipherCipher.process(byte[], int, int, byte[], int)处理完数据后非完整块数据,此方法用于处理块中剩余的bytespublic byte[] processFinal(byte[] in)
CipherprocessFinal in interface Cipherin - 输入数据public byte[] processFinal(byte[] data,
int inOffset,
int inputLen)
CipherprocessFinal in interface Cipherdata - 输入数据inOffset - 输入开始的 input中的偏移量inputLen - 输入长度Cipher.process(byte[], int, int, byte[], int),
Cipher.doFinal(byte[], int)Copyright © 2025. All rights reserved.