public final class CryptUtils extends Object
| 限定符和类型 | 类和说明 |
|---|---|
static class |
CryptUtils.AES
AES对称加密
|
static class |
CryptUtils.Algorithm
一些算法
|
static class |
CryptUtils.DSA
DSA签名认证
|
static class |
CryptUtils.KeyGen
秘钥生成
KeyGenerator和SecretKeyFactory,都是javax.crypto包的,生成的key主要是提供给AES,DES,3DES,MD5,SHA1等对称单向加密算法。
|
static class |
CryptUtils.RSA
RSA非对称加密
|
| 限定符和类型 | 字段和说明 |
|---|---|
static String |
MODE_CBC |
static String |
MODE_CFB |
static String |
MODE_CTR |
static String |
MODE_ECB |
static String |
MODE_OFB |
static String |
PADDING_NO_PADDING |
static String |
PADDING_PKCS5 |
| 限定符和类型 | 方法和说明 |
|---|---|
static String |
decrypt(byte[] data,
Key key)
通用解密方法,使用默认参数
|
static String |
decrypt(byte[] data,
String algorithm,
Key key,
byte[] iv,
int blockSize)
通用解密方法
|
static byte[] |
digest(String data,
String algorithm)
通用摘要方法
|
static byte[] |
encrypt(String data,
Key key)
通用加密算法,使用默认参数
|
static byte[] |
encrypt(String data,
String algorithm,
Key key,
byte[] iv,
int blockSize)
通用加密算法
|
static byte[] |
fromHex(String hexStr)
16进制解码
|
static byte[] |
sign(String data,
String algorithm,
PrivateKey privateKey)
通用签名方法,私钥签名
|
static String |
toHex(byte[] data)
16进制编码
|
static boolean |
verify(String data,
String algorithm,
PublicKey publicKey,
byte[] sign)
通用验证方法,公钥验证
|
public static byte[] encrypt(String data, String algorithm, Key key, byte[] iv, int blockSize)
data - 待加密数据algorithm - 算法[/模式][/填充]key - 密钥iv - 偏移向量,对称加密ECB模式和非对称加密传nullblockSize - 分段加密数据块大小,传-1不分段public static byte[] encrypt(String data, Key key)
data - 待加密数据key - 密钥public static String decrypt(byte[] data, String algorithm, Key key, byte[] iv, int blockSize)
data - 待解密数据algorithm - 算法[/模式][/填充]key - 密钥iv - 偏移向量,对称加密ECB模式和非对称加密传nullblockSize - 分段加密数据块大小,传-1不分段public static String decrypt(byte[] data, Key key)
data - 待解密数据key - 密钥public static byte[] sign(String data, String algorithm, PrivateKey privateKey)
data - 待签名数据algorithm - 算法[/模式][/填充]privateKey - 私钥public static boolean verify(String data, String algorithm, PublicKey publicKey, byte[] sign)
data - 待验证数据algorithm - 算法[/模式][/填充]publicKey - 公钥sign - 签名public static byte[] digest(String data, String algorithm)
data - 待摘要信息algorithm - 摘要算法public static String toHex(byte[] data)
data - 数据public static byte[] fromHex(String hexStr)
hexStr - 16进制字符串Copyright © 2023. All rights reserved.