public class RSAUtil extends Object
| 构造器和说明 |
|---|
RSAUtil() |
| 限定符和类型 | 方法和说明 |
|---|---|
static String |
decrypt(PrivateKey privateKey,
String enStr)
功能描述: 使用私钥对明文密文进行解密
|
static String |
decrypt(String privateKeystore,
String enStr)
功能描述: 使用keystore对密文进行解密
|
static String |
encrypt(PrivateKey privateKey,
String plainText)
功能描述: 使用公钥对明文进行加密,返回BASE64编码的字符串
|
static String |
encrypt(String publicKeystore,
String plainText)
功能描述: 使用keystore对明文进行加密
|
static Map<String,String> |
generateKeyPair(String filePath)
功能描述: 生成密钥对
|
static String |
getKeyString(Key key)
功能描述: 得到密钥字符串(经过base64编码)
|
static PrivateKey |
getPrivateKey(String key)
功能描述: 获取私钥
|
static PublicKey |
getPublicKey(String key)
功能描述: 获取公钥
|
public static Map<String,String> generateKeyPair(String filePath)
filePath - 生成密钥的路径public static PublicKey getPublicKey(String key) throws Exception
key - 密钥字符串(经过base64编码)Exception - PublicKey
date: 2018年4月11日 下午4:30:53public static PrivateKey getPrivateKey(String key) throws Exception
key - 密钥字符串(经过base64编码)Exception - PrivateKey
date: 2018年4月11日 下午4:31:09public static String getKeyString(Key key) throws Exception
key - Exception - String
date: 2018年4月11日 下午4:31:21public static String encrypt(PrivateKey privateKey, String plainText)
privateKey - plainText - public static String encrypt(String publicKeystore, String plainText)
publicKeystore - 公钥文件路径plainText - 明文public static String decrypt(PrivateKey privateKey, String enStr)
privateKey - enStr - Copyright © 2018. All rights reserved.