public class AESPKCS7 extends Object
CBC 模式
PKCS7Padding 填充模式
CBC模式需要添加一个参数iv
介于java 不支持PKCS7Padding,只支持PKCS5Padding 但是PKCS7Padding 和 PKCS5Padding 没有什么区别 要实现在java端用PKCS7Padding填充,需要用到bouncycastle组件来实现
| 构造器和说明 |
|---|
AESPKCS7() |
| 限定符和类型 | 方法和说明 |
|---|---|
byte[] |
decrypt(byte[] encryptedData,
byte[] keyBytes,
byte[] iv)
解密方法
|
byte[] |
decryptWithIVBase64(String encryptedDataBase64,
byte[] keyBytes,
int ivLength)
解密方法
|
byte[] |
encrypt(byte[] content,
byte[] keyBytes,
byte[] iv)
加密方法, 不对结果进行base64二次加密
|
String |
encryptWithIVBase64(byte[] content,
byte[] keyBytes,
byte[] iv)
加密方法
|
public byte[] encrypt(byte[] content,
byte[] keyBytes,
byte[] iv)
content - 要加密的字符串keyBytes - 加密密钥iv - 向量LeonaRuntimeException - 加密异常public String encryptWithIVBase64(byte[] content, byte[] keyBytes, byte[] iv)
content - 要加密的字符串keyBytes - 加密密钥iv - 向量LeonaRuntimeException - 加密异常public byte[] decrypt(byte[] encryptedData,
byte[] keyBytes,
byte[] iv)
encryptedData - 要解密的字符串keyBytes - 解密密钥iv - 向量LeonaRuntimeException - 解密异常public byte[] decryptWithIVBase64(String encryptedDataBase64, byte[] keyBytes, int ivLength)
encryptedDataBase64 - 要解密的字符串, 格式为base64Encode(iv + encryptedBody)keyBytes - 解密密钥ivLength - 附加到密文最前方的iv长度LeonaRuntimeException - 解密异常Copyright © 2020. All rights reserved.