mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-05-09 23:51:34 +08:00
fix code
This commit is contained in:
parent
a07317fee4
commit
3bb4cb3012
@ -19,7 +19,11 @@ package org.dromara.hutool.crypto;
|
|||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 密码接口,提供统一的API,用于兼容和统一JCE和BouncyCastle等库的操作
|
* 密码接口,提供统一的API,用于兼容和统一JCE和BouncyCastle等库的操作<br>
|
||||||
|
* <ul>
|
||||||
|
* <li>process和doFinal组合使用,用于分块加密或解密</li>
|
||||||
|
* <li>processFinal默认处理并输出小于块的数据,或一次性数据</li>
|
||||||
|
* </ul>
|
||||||
*
|
*
|
||||||
* @author Looly
|
* @author Looly
|
||||||
* @since 6.0.0
|
* @since 6.0.0
|
||||||
|
@ -112,6 +112,38 @@ public class JceCipher extends SimpleWrapper<javax.crypto.Cipher> implements Cip
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// region ----- process
|
||||||
|
/**
|
||||||
|
* 继续多部分加密或解密操作(取决于此密码的初始化方式),处理另一个数据部分。
|
||||||
|
* 第一inputLen字节在input缓冲区中,从inputOffset以下,被处理,并且结果被存储在output缓冲器。
|
||||||
|
*
|
||||||
|
* @param in 输入缓冲区
|
||||||
|
* @param inOff 输入开始的 input中的偏移量
|
||||||
|
* @param len 输入长度
|
||||||
|
* @return 带有结果的新缓冲区,如果底层密码是块密码且输入数据太短而不能产生新块,则返回null。
|
||||||
|
*/
|
||||||
|
public byte[] process(final byte[] in, final int inOff, final int len) {
|
||||||
|
return this.raw.update(in, inOff, len);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 继续多部分加密或解密操作(取决于此密码的初始化方式),处理另一个数据部分。
|
||||||
|
* 第一inputLen字节在input缓冲区中,从inputOffset以下,被处理,并且结果被存储在output缓冲器。
|
||||||
|
*
|
||||||
|
* @param in 输入缓冲区
|
||||||
|
* @param inOff 输入开始的 input中的偏移量
|
||||||
|
* @param len 输入长度
|
||||||
|
* @param out 结果的缓冲区
|
||||||
|
* @return 存储在 output的字节数
|
||||||
|
*/
|
||||||
|
public int process(final byte[] in, final int inOff, final int len, final byte[] out) {
|
||||||
|
try {
|
||||||
|
return this.raw.update(in, inOff, len, out);
|
||||||
|
} catch (final ShortBufferException e) {
|
||||||
|
throw new CryptoException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int process(final byte[] in, final int inOff, final int len, final byte[] out, final int outOff) {
|
public int process(final byte[] in, final int inOff, final int len, final byte[] out, final int outOff) {
|
||||||
try {
|
try {
|
||||||
@ -120,6 +152,7 @@ public class JceCipher extends SimpleWrapper<javax.crypto.Cipher> implements Cip
|
|||||||
throw new CryptoException(e);
|
throw new CryptoException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// endregion
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int doFinal(final byte[] out, final int outOff) {
|
public int doFinal(final byte[] out, final int outOff) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user