public class AES extends Object
| 限定符和类型 | 字段和说明 |
|---|---|
private static int |
AES_KEY_LENGTH |
private static String |
KEY_ALGORITHM
默认KEY填充算法
|
private static String |
KEY_ALGORITHM_CIPHER
"算法/模式/补码方式"
|
| 构造器和说明 |
|---|
AES() |
| 限定符和类型 | 方法和说明 |
|---|---|
static String |
aesDecrypt(String sSrc,
String spKey)
解密
|
static String |
aesEncrypt(String sSrc,
String spKey)
加密
|
private static byte[] |
getBytesBySpkey(String spKey)
AES 密钥长度规定为16位,这里判断spKey
1、长度不满足16位的统一前置填充字符'a
2、大于长度的统一截取前16位
|
static void |
main(String[] args) |
private static final int AES_KEY_LENGTH
private static byte[] getBytesBySpkey(String spKey)
spKey - 密钥public static String aesEncrypt(String sSrc, String spKey) throws Exception
sSrc - 待加密字符串spKey - 密钥Exceptionpublic static String aesDecrypt(String sSrc, String spKey) throws Exception
sSrc - 待解密字符串spKey - 密钥ExceptionCopyright © 2022. All rights reserved.