版本升级2.13.2

This commit is contained in:
egzosn
2020-06-01 23:12:18 +08:00
parent a41615e9a2
commit b0e83247dc
8 changed files with 32 additions and 24 deletions

View File

@@ -175,7 +175,8 @@ public class RSA{
* @param privateKey 商户私钥
* @param characterEncoding 编码格式
* @return 解密后的字符串
* @throws Exception 解密异常
* @throws GeneralSecurityException 解密异常
* @throws IOException IOException
*/
public static String decrypt(String content, String privateKey, String characterEncoding) throws GeneralSecurityException, IOException {
PrivateKey prikey = getPrivateKey(privateKey);

View File

@@ -63,7 +63,8 @@ public class RSA2 {
* @param privateKey 商户私钥
* @param characterEncoding 编码格式
* @return 解密后的字符串
* @throws Exception 解密异常
* @throws GeneralSecurityException 解密异常
* @throws IOException 解密异常
*/
public static String decrypt(String content, String privateKey, String characterEncoding) throws GeneralSecurityException, IOException {
return RSA.decrypt(content, privateKey, characterEncoding);
@@ -73,14 +74,23 @@ public class RSA2 {
/**
* 得到私钥
* @param key 密钥字符串经过base64编码
* @throws Exception 加密异常
* @throws GeneralSecurityException 加密异常
* @return 私钥
*/
public static PrivateKey getPrivateKey(String key) throws Exception {
public static PrivateKey getPrivateKey(String key) throws GeneralSecurityException {
return RSA.getPrivateKey(key);
}
/**
*
* @param content 加密文本
* @param publicKey 公钥
* @param cipherAlgorithm 算法
* @param characterEncoding 编码类型
* @return 加密后文本
* @throws GeneralSecurityException 加密异常
* @throws IOException IOException
*/
public static String encrypt(String content, String publicKey, String cipherAlgorithm, String characterEncoding ) throws GeneralSecurityException, IOException {
return Base64.encode(RSA.encrypt(content.getBytes(characterEncoding), RSA.getPublicKey(publicKey), 2048, 11, cipherAlgorithm));
}