@@ -63,7 +63,8 @@ public static boolean verify(String content, String sign, PublicKey publicKey, S
6363 * @param privateKey 商户私钥
6464 * @param characterEncoding 编码格式
6565 * @return 解密后的字符串
66- * @throws Exception 解密异常
66+ * @throws GeneralSecurityException 解密异常
67+ * @throws IOException 解密异常
6768 */
6869 public static String decrypt (String content , String privateKey , String characterEncoding ) throws GeneralSecurityException , IOException {
6970 return RSA .decrypt (content , privateKey , characterEncoding );
@@ -73,14 +74,23 @@ public static String decrypt(String content, String privateKey, String character
7374 /**
7475 * 得到私钥
7576 * @param key 密钥字符串(经过base64编码)
76- * @throws Exception 加密异常
77+ * @throws GeneralSecurityException 加密异常
7778 * @return 私钥
7879 */
79- public static PrivateKey getPrivateKey (String key ) throws Exception {
80+ public static PrivateKey getPrivateKey (String key ) throws GeneralSecurityException {
8081 return RSA .getPrivateKey (key );
8182 }
8283
83-
84+ /**
85+ *
86+ * @param content 加密文本
87+ * @param publicKey 公钥
88+ * @param cipherAlgorithm 算法
89+ * @param characterEncoding 编码类型
90+ * @return 加密后文本
91+ * @throws GeneralSecurityException 加密异常
92+ * @throws IOException IOException
93+ */
8494 public static String encrypt (String content , String publicKey , String cipherAlgorithm , String characterEncoding ) throws GeneralSecurityException , IOException {
8595 return Base64 .encode (RSA .encrypt (content .getBytes (characterEncoding ), RSA .getPublicKey (publicKey ), 2048 , 11 , cipherAlgorithm ));
8696 }
0 commit comments