public static class CodecUtils.CodecHelper extends Object
Modifier and Type | Field and Description |
---|---|
protected String |
CIPHER_ALGORITHM
加密/解密算法/工作模式/填充方式
|
protected String |
KEY_ALGORITHM
密钥算法
|
protected int |
KEY_SIZE |
Constructor and Description |
---|
CodecHelper(int keySize,
String keyAlgorithm,
String cipherAlgorithm) |
CodecHelper(int keySize,
String keyAlgorithm,
String cipherAlgorithm,
Provider provider) |
Modifier and Type | Method and Description |
---|---|
byte[] |
decrypt(byte[] data,
byte[] key)
解密数据
|
String |
decrypt(String data,
String key) |
byte[] |
encrypt(byte[] data,
byte[] key)
加密数据
|
String |
encrypt(String data,
String key) |
protected Cipher |
getCipherInstance() |
byte[] |
initKey()
生成密钥
|
String |
initKeyToString() |
Key |
toKey(byte[] key)
转换密钥
|
protected final String KEY_ALGORITHM
protected final String CIPHER_ALGORITHM
protected final int KEY_SIZE
protected Cipher getCipherInstance() throws NoSuchPaddingException, NoSuchAlgorithmException
public byte[] initKey() throws Exception
Exception
- if an error occurs.public Key toKey(byte[] key) throws Exception
key
- 二进制密钥Exception
- if an error occurs.public byte[] encrypt(byte[] data, byte[] key) throws Exception
data
- 待加密数据key
- 密钥Exception
- if an error occurs.public byte[] decrypt(byte[] data, byte[] key) throws Exception
data
- 待解密数据key
- 密钥Exception
- if an error occurs.Copyright © 2022. All rights reserved.