From b2e4845b84b23aa3f9cc01141c74a8a27c56c17a Mon Sep 17 00:00:00 2001 From: 13693261870 <252740454@qq.com> Date: 星期一, 13 三月 2023 10:52:39 +0800 Subject: [PATCH] 1 --- src/main/java/com/lf/server/helper/RsaHelper.java | 11 +++++------ 1 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/lf/server/helper/RsaHelper.java b/src/main/java/com/lf/server/helper/RsaHelper.java index c6d38e7..0b10dd5 100644 --- a/src/main/java/com/lf/server/helper/RsaHelper.java +++ b/src/main/java/com/lf/server/helper/RsaHelper.java @@ -7,6 +7,7 @@ import javax.crypto.Cipher; import java.io.*; +import java.nio.charset.StandardCharsets; import java.security.*; import java.security.interfaces.RSAPrivateKey; import java.security.interfaces.RSAPublicKey; @@ -15,11 +16,9 @@ import java.util.HashMap; import java.util.Map; - /** - * RSA宸ュ叿绫� 榛樿闀垮害涓�2048浣� - * @author LinTao - * @date 2022/2/13 + * RSA宸ュ叿绫� + * @author WWW */ public class RsaHelper { /** @@ -171,7 +170,7 @@ */ public static String decrypt(String str) throws Exception { // 64浣嶈В鐮佸姞瀵嗗悗鐨勫瓧绗︿覆 - byte[] inputByte = Base64.decodeBase64(str.getBytes("UTF-8")); + byte[] inputByte = Base64.decodeBase64(str.getBytes(StandardCharsets.UTF_8)); // Base64缂栫爜鐨勭閽� byte[] decoded = Base64.decodeBase64(getPrivateKey()); @@ -203,7 +202,7 @@ Cipher cipher = Cipher.getInstance("RSA"); cipher.init(Cipher.ENCRYPT_MODE, pubKey); - String outStr = Base64.encodeBase64String(cipher.doFinal(str.getBytes("UTF-8"))); + String outStr = Base64.encodeBase64String(cipher.doFinal(str.getBytes(StandardCharsets.UTF_8))); return outStr; } -- Gitblit v1.9.3