public class AesUtils extends Object
| 构造器和说明 |
|---|
AesUtils() |
| 限定符和类型 | 方法和说明 |
|---|---|
static String |
decodeBase64(String content,
String pwdKey)
base64解密后aes解密
|
static byte[] |
decrypt(byte[] content,
String pwdKey)
解密
|
static String |
encodeBase64(String content,
String pwdKey)
base64 加密后aes加密
|
static byte[] |
encrypt(String content,
String pwdKey)
加密
|
static String |
generateSecret(int keySize)
生成随机密钥
|
static void |
main(String[] args) |
public static String generateSecret(int keySize)
keySize - 密钥大小: 128 192 256
128 返回16位key
192 返回24位key
256 返回32位keypublic static byte[] encrypt(String content, String pwdKey) throws GeneralSecurityException, UnsupportedEncodingException
content - 需要加密的字符串pwdKey - 密钥GeneralSecurityException - errorUnsupportedEncodingExceptionpublic static String encodeBase64(String content, String pwdKey) throws GeneralSecurityException, UnsupportedEncodingException
content - 内容pwdKey - 密钥GeneralSecurityException - errUnsupportedEncodingException - errpublic static byte[] decrypt(byte[] content,
String pwdKey)
throws GeneralSecurityException,
UnsupportedEncodingException
content - 需要解密的字符串pwdKey - 密钥GeneralSecurityExceptionUnsupportedEncodingExceptionpublic static String decodeBase64(String content, String pwdKey) throws GeneralSecurityException, UnsupportedEncodingException
content - 内容pwdKey - 密钥GeneralSecurityException - errorUnsupportedEncodingException - errCopyright © 2020. All rights reserved.