public class AESUtils extends Object
| 限定符和类型 | 字段和说明 |
|---|---|
static boolean |
initialized |
| 构造器和说明 |
|---|
AESUtils() |
| 限定符和类型 | 方法和说明 |
|---|---|
static String |
byte2hex(byte[] b)
字节数组转成16进制字符串
|
static byte[] |
decrypt(byte[] content,
byte[] key)
通过byte[]类型的密钥解密byte[]
|
static String |
decrypt(String content,
byte[] key)
通过byte[]类型的密钥 解密String类型的密文
|
static String |
decrypt(String content,
String key)
通过String类型的密钥 解密String类型的密文
|
static byte[] |
encrypt(byte[] content,
byte[] key)
加密字节数据
|
static String |
encrypt(String content,
byte[] key)
通过byte[]类型的密钥加密String
|
static String |
encrypt(String content,
String key)
通过String类型的密钥加密String
|
static AlgorithmParameters |
generateIV(byte[] iv)
生成iv
|
static SecretKeySpec |
generateKey()
生成一个AES密钥对象
|
static String |
generateKeyString()
生成一个AES密钥字符串
|
static String |
getKey()
获取对称加密随机生成的秘钥串
|
static boolean |
initialize()
导入provider
|
static char |
PKCS7Chr(int a)
将数字转化成ASCII码对应的字符,用于对明文进行补码
|
static byte[] |
PKCS7Decode(byte[] decrypted)
删除解密后明文的补位字符
|
static byte[] |
PKCS7Encode(int count)
获得对明文进行补位填充的字节.
|
static byte[] |
wxDecrypt(byte[] content,
byte[] key,
byte[] iv)
通过byte[]类型的密钥解密byte[],主要用于微信平台(小程序/开放平台)数据解密
|
static String |
wxDecrypt(String content,
String sessionKey,
String iv)
微信平台(小程序/开放平台)数据解密
|
public static boolean initialize()
public static SecretKeySpec generateKey()
public static String generateKeyString()
public static byte[] encrypt(byte[] content,
byte[] key)
content - key - public static String encrypt(String content, byte[] key)
content - key - public static String encrypt(String content, String key)
content - key - public static byte[] decrypt(byte[] content,
byte[] key)
content - 源数据key - 密钥public static AlgorithmParameters generateIV(byte[] iv) throws Exception
iv - iv字节数据Exceptionpublic static String decrypt(String content, String key)
content - key - public static byte[] wxDecrypt(byte[] content,
byte[] key,
byte[] iv)
content - key - public static String wxDecrypt(String content, String sessionKey, String iv)
content - 待解密数据sessionKey - 密钥iv - IV向量public static String decrypt(String content, byte[] key)
content - 待解密数据key - 密钥public static String byte2hex(byte[] b)
b - 字节数组public static String getKey()
public static byte[] PKCS7Encode(int count)
count - 需要进行填充补位操作的明文字节个数public static byte[] PKCS7Decode(byte[] decrypted)
decrypted - 解密后的明文public static char PKCS7Chr(int a)
a - 需要转化的数字Copyright © 2022. All rights reserved.