From b6b0cb226fcf184525ee7b36af3a09471e9c0057 Mon Sep 17 00:00:00 2001 From: 13693261870 <252740454@qq.com> Date: 星期一, 25 三月 2024 11:29:33 +0800 Subject: [PATCH] 修改数据统计的查询条件 --- src/main/java/com/lf/server/helper/RsaHelper.java | 27 ++++++++++++++++++--------- 1 files changed, 18 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/lf/server/helper/RsaHelper.java b/src/main/java/com/lf/server/helper/RsaHelper.java index cf73452..0b10dd5 100644 --- a/src/main/java/com/lf/server/helper/RsaHelper.java +++ b/src/main/java/com/lf/server/helper/RsaHelper.java @@ -1,10 +1,13 @@ package com.lf.server.helper; -import org.apache.tomcat.util.codec.binary.Base64; +import org.apache.commons.codec.binary.Base64; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import org.springframework.core.io.ClassPathResource; 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; @@ -13,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 { /** @@ -30,12 +31,20 @@ */ private static String publicKey; + /** + * 瀵嗛挜绠楁硶 + */ private static final String KEY_ALGORITHM = "RSA"; /** * RSA瀵嗛挜闀垮害锛�1024 鎴� 2048 */ private static final int DEFAULT_RSA_KEY_SIZE = 1024; + + /** + * 鏃ュ織 + */ + private final static Log log = LogFactory.getLog(RsaHelper.class); /** * 鐢熸垚鍏閽� @@ -145,8 +154,8 @@ // 寰楀埌绉侀挜瀛楃涓� String pri = new String(Base64.encodeBase64(keyPair.getPrivate().getEncoded())); result.put("privateKey", pri); - } catch (GeneralSecurityException e) { - e.printStackTrace(); + } catch (Exception ex) { + log.error(ex.getMessage(), ex); } return result; @@ -161,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()); @@ -193,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