From bff933481e54ff32e1b7d907c1f91cab605bb4e0 Mon Sep 17 00:00:00 2001 From: zack Date: Fri, 15 Jan 2021 15:15:31 +0800 Subject: [PATCH] =?UTF-8?q?=E6=97=A0JIRA=E4=BB=BB=E5=8A=A1=20=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D=E4=B8=80=E4=BA=9Bdemo=E7=BC=96=E8=AF=91=E9=97=AE?= =?UTF-8?q?=E9=A2=98,=E5=B7=B2=E7=BB=8F=E7=A8=8B=E5=BA=8F=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E9=9B=86=E9=80=BB=E8=BE=91=E4=B8=8D=E4=B8=A5=E8=B0=A8?= =?UTF-8?q?=E9=97=AE=E9=A2=98(getColumnName=E5=8F=AF=E8=83=BD=E6=8A=A5?= =?UTF-8?q?=E9=94=99NPE)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/fr/data/ParamTableDataDemo.java | 2 ++ src/main/java/com/fr/output/OutputExcel.java | 2 +- src/main/java/com/fr/privilege/RSAUtil.java | 15 ++++++++------- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/fr/data/ParamTableDataDemo.java b/src/main/java/com/fr/data/ParamTableDataDemo.java index ba217bf..b5c2cd8 100644 --- a/src/main/java/com/fr/data/ParamTableDataDemo.java +++ b/src/main/java/com/fr/data/ParamTableDataDemo.java @@ -50,11 +50,13 @@ public class ParamTableDataDemo extends AbstractTableData { */ @Override public int getColumnCount() { + init(); return columnNum; } @Override public String getColumnName(int columnIndex) { + init(); return columnNames[columnIndex]; } diff --git a/src/main/java/com/fr/output/OutputExcel.java b/src/main/java/com/fr/output/OutputExcel.java index 72d6469..2df1026 100644 --- a/src/main/java/com/fr/output/OutputExcel.java +++ b/src/main/java/com/fr/output/OutputExcel.java @@ -9,9 +9,9 @@ import com.fr.stable.ArrayUtils; import java.io.BufferedInputStream; import java.io.BufferedOutputStream; import java.io.File; -import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; +import java.io.InputStream; import java.io.OutputStream; import java.util.Map; diff --git a/src/main/java/com/fr/privilege/RSAUtil.java b/src/main/java/com/fr/privilege/RSAUtil.java index 5a5d848..53cfff3 100644 --- a/src/main/java/com/fr/privilege/RSAUtil.java +++ b/src/main/java/com/fr/privilege/RSAUtil.java @@ -1,5 +1,8 @@ package com.fr.privilege; +import com.fr.third.org.bouncycastle.jce.provider.BouncyCastleProvider; + +import javax.crypto.Cipher; import java.io.ByteArrayOutputStream; import java.io.FileInputStream; import java.io.FileOutputStream; @@ -19,8 +22,6 @@ import java.security.spec.InvalidKeySpecException; import java.security.spec.RSAPrivateKeySpec; import java.security.spec.RSAPublicKeySpec; -import javax.crypto.Cipher; - /** * RSA 工具类。提供加密,解密,生成密钥对等方法。 * 需要到http://www.bouncycastle.org下载bcprov-jdk14-123.jar。 @@ -36,7 +37,7 @@ public class RSAUtil { public static KeyPair generateKeyPair() throws Exception { try { KeyPairGenerator keyPairGen = KeyPairGenerator.getInstance("RSA", - new org.bouncycastle.jce.provider.BouncyCastleProvider()); + new BouncyCastleProvider()); final int KEY_SIZE = 1024;// 没什么好说的了,这个值关系到块加密的大小,可以更改,但是不要太大,否则效率会低 keyPairGen.initialize(KEY_SIZE, new SecureRandom()); KeyPair keyPair = keyPairGen.generateKeyPair(); @@ -79,7 +80,7 @@ public class RSAUtil { KeyFactory keyFac = null; try { keyFac = KeyFactory.getInstance("RSA", - new org.bouncycastle.jce.provider.BouncyCastleProvider()); + new BouncyCastleProvider()); } catch (NoSuchAlgorithmException ex) { throw new Exception(ex.getMessage()); } @@ -106,7 +107,7 @@ public class RSAUtil { KeyFactory keyFac = null; try { keyFac = KeyFactory.getInstance("RSA", - new org.bouncycastle.jce.provider.BouncyCastleProvider()); + new BouncyCastleProvider()); } catch (NoSuchAlgorithmException ex) { throw new Exception(ex.getMessage()); } @@ -133,7 +134,7 @@ public class RSAUtil { public static byte[] encrypt(PublicKey pk, byte[] data) throws Exception { try { Cipher cipher = Cipher.getInstance("RSA", - new org.bouncycastle.jce.provider.BouncyCastleProvider()); + new BouncyCastleProvider()); cipher.init(Cipher.ENCRYPT_MODE, pk); int blockSize = cipher.getBlockSize();// 获得加密块大小,如:加密前数据为128个byte,而key_size=1024 // 加密块大小为127 @@ -177,7 +178,7 @@ public class RSAUtil { public static byte[] decrypt(PrivateKey pk, byte[] raw) throws Exception { try { Cipher cipher = Cipher.getInstance("RSA", - new org.bouncycastle.jce.provider.BouncyCastleProvider()); + new BouncyCastleProvider()); cipher.init(cipher.DECRYPT_MODE, pk); int blockSize = cipher.getBlockSize(); ByteArrayOutputStream bout = new ByteArrayOutputStream(64);