public class RSAUtils extends Object
| Constructor and Description |
|---|
RSAUtils() |
| Modifier and Type | Method and Description |
|---|---|
static String |
decrypt(String str,
String privateKey)
RSA私钥解密
|
static String |
encrypt(String str,
String publicKey)
RSA公钥加密
|
static Map<Integer,String> |
genKeyPair(int keySize)
随机生成密钥对
|
static PrivateKey |
getPrivateKey(String base64PrivateKey) |
static PublicKey |
getPublicKey(String base64PublicKey) |
public static final String ALGORITHM
public static Map<Integer,String> genKeyPair(int keySize)
NoSuchAlgorithmExceptionpublic static String encrypt(String str, String publicKey) throws Exception
str - 加密字符串publicKey - 公钥Exception - 加密过程中的异常信息public static String decrypt(String str, String privateKey) throws Exception
str - 加密字符串privateKey - 私钥Exception - 解密过程中的异常信息public static PrivateKey getPrivateKey(String base64PrivateKey)
Copyright © 2020. All rights reserved.