Skip to content

Commit f5ee1c8

Browse files
zhouhuan751312gitee-org
authored andcommitted
!20 紧急修复查询信息字段不存在错误、获取IP信息问题
Merge pull request !20 from 勤劳的小蜜蜂/dev
2 parents e345547 + 2f76f48 commit f5ee1c8

File tree

17 files changed

+98
-240
lines changed

17 files changed

+98
-240
lines changed

fast-admin/src/main/resources/run/runFASTOSLinux.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ start(){
7272
echo -e "\033[31m######################################################################################\033[0m"
7373
echo -e "\033[32m#########运行版本${APP_VERSION}###################################\033[0m"
7474
#-Djava.library.path 若你的项目需要引用dll或os库 需要放在lib目录下面
75-
nohup java -Dfile.encoding=utf-8 -Djava.library.path=${APP_PATH}/lib -Xms512m -Xmx1024m -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=512m -jar ${APP_NAME} >sysTemp.out 2>&1 &
75+
nohup java -Dfile.encoding=utf-8 -Djava.library.path=${APP_PATH}/lib -Xms1024m -Xmx1024m -XX:MetaspaceSize=256m -XX:MaxMetaspaceSize=256m -XX:+HeapDumpOnOutOfMemoryError -jar ${APP_NAME} >sysTemp.out 2>&1 &
7676

7777
sleep 10
7878

fast-common/src/main/java/com/j2eefast/common/core/crypto/EncryptUtil.java

+35-26
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ else if (pinFmt == EncryptConst.ENCRY_PIN_ISO9564_1)
5555

5656
/**
5757
* ������DES���ܵ���Կ
58-
* @param short keyLen Ҫ��ɵ���Կ����?��λ�ֽڣ�8/16/24
58+
* @param keyLen Ҫ��ɵ���Կ����?��λ�ֽڣ�8/16/24
5959
* @return byte[] ������Կֵ
6060
* @throws EncryptException
6161
*/
@@ -140,7 +140,7 @@ else if (keyValue.length == 24)
140140
* @param data ��Ҫ���ܵ����?
141141
* @param initIV ��ʼ����������CBC���ܣ���Ϊ��Ĭ��Ϊ0
142142
* @return byte[] ���ܺ�����
143-
* @throws util.EncryptException
143+
* @throws EncryptException
144144
*/
145145
public static byte[] doEncrypt(byte mode, byte[] keyValue, byte[] data,
146146
byte[] initIV) throws EncryptException
@@ -184,8 +184,9 @@ else if (mode == EncryptConst.ENCRY_3DES_CBC)
184184
if (initIV != null)
185185
{
186186
int nLen = initIV.length;
187-
if (nLen > 8)
187+
if (nLen > 8) {
188188
nLen = 8;
189+
}
189190
System.arraycopy(initIV, 0, iv, 0, nLen);
190191
}
191192
IvParameterSpec spec = new IvParameterSpec(iv);
@@ -211,7 +212,7 @@ else if (mode == EncryptConst.ENCRY_3DES_CBC)
211212
* @param raw ����ܵ����
212213
* @param initIV ��ʼ����������CBC���ܣ���Ϊ��Ĭ��Ϊ0
213214
* @return byte[] ���ܺ�����
214-
* @throws util.EncryptException
215+
* @throws EncryptException
215216
*/
216217
public static byte[] doDecrypt(byte mode, byte[] keyValue, byte[] raw,byte[] initIV) throws EncryptException
217218
{
@@ -254,8 +255,9 @@ else if (mode == EncryptConst.DECRY_3DES_CBC)
254255
if (initIV != null)
255256
{
256257
int nLen = initIV.length;
257-
if (nLen > 8)
258+
if (nLen > 8) {
258259
nLen = 8;
260+
}
259261
System.arraycopy(initIV, 0, iv, 0, nLen);
260262
}
261263
IvParameterSpec spec = new IvParameterSpec(iv);
@@ -281,7 +283,7 @@ else if (mode == EncryptConst.DECRY_3DES_CBC)
281283
* @param data �����MAC�����?
282284
* @param initIV ��ʼ������Ϊ��Ĭ��Ϊ0
283285
* @return byte[] ������MAC
284-
* @throws util.EncryptException
286+
* @throws EncryptException
285287
* 1,mac,data,null
286288
*/
287289
public static byte[] generateMac(byte mode, byte[] keyValue, byte[] data,byte[] initIV) throws EncryptException
@@ -339,8 +341,9 @@ else if (keyValue.length == 24)
339341
if (initIV != null)
340342
{
341343
int nLen = initIV.length;
342-
if (nLen > 8)
344+
if (nLen > 8) {
343345
nLen = 8;
346+
}
344347
System.arraycopy(initIV, 0, iv, 0, nLen);
345348
}
346349
IvParameterSpec spec = new IvParameterSpec(iv);
@@ -369,8 +372,9 @@ else if (keyValue.length == 24)
369372

370373
public static byte[] formatPIN(byte[] pin)
371374
{
372-
if (pin == null)
375+
if (pin == null) {
373376
pin = new byte[0];
377+
}
374378
int nLen = pin.length;
375379
byte[] fmtPin = new byte[16];
376380
fmtPin[0] = '0';
@@ -386,8 +390,9 @@ public static byte[] formatPIN(byte[] pin)
386390

387391
public static byte[] formatSM4PIN(byte[] pin)
388392
{
389-
if (pin == null)
390-
pin = new byte[0];
393+
if (pin == null) {
394+
pin = new byte[0];
395+
}
391396
int nLen = pin.length;
392397
byte[] fmtPin = new byte[32];
393398
fmtPin[0] = (byte)'0';
@@ -404,8 +409,9 @@ public static byte[] formatSM4PIN(byte[] pin)
404409

405410
public static byte[] formatPIN9564(byte[] pin)
406411
{
407-
if (pin == null)
412+
if (pin == null) {
408413
pin = new byte[0];
414+
}
409415
int nLen = pin.length;
410416
byte[] fmtPin = new byte[16];
411417
fmtPin[0] = '1';
@@ -425,15 +431,17 @@ public static byte[] formatPIN9564(byte[] pin)
425431
public static byte[] formatAccountNo(byte[] accountNo)
426432
{
427433
byte[] accountNoPart = new byte[16];
428-
for (int i = 0; i < 16; i++)
434+
for (int i = 0; i < 16; i++) {
429435
accountNoPart[i] = '0';
430-
if (accountNo.length > 12)
436+
}
437+
if (accountNo.length > 12) {
431438
System.arraycopy(accountNo, accountNo.length - 13, accountNoPart,
432439
4, 12);
433-
else {//不含最后一位校验位,不足12位左补0
440+
} else {//不含最后一位校验位,不足12位左补0
434441
byte[] temp = new byte[12];
435-
for (int i = 0; i < 12; i++)
442+
for (int i = 0; i < 12; i++) {
436443
temp[i] = '0';
444+
}
437445
System.arraycopy(accountNo, 0, temp, 12-accountNo.length, accountNo.length);
438446
System.arraycopy(temp, 0, accountNoPart, 4, temp.length);
439447
}
@@ -454,16 +462,18 @@ public static byte[] formatAccountNo(byte[] accountNo)
454462
public static byte[] formatSM4AccountNo(byte[] accountNo)
455463
{
456464
byte[] accountNoPart = new byte[32];
457-
for (int i = 0; i < 32; i++)
458-
accountNoPart[i] = (byte)'0';
459-
if (accountNo.length > 12)
460-
System.arraycopy(accountNo, accountNo.length - 13, accountNoPart,
461-
20, 12);
462-
else {
465+
for (int i = 0; i < 32; i++) {
466+
accountNoPart[i] = (byte)'0';
467+
}
468+
if (accountNo.length > 12) {
469+
System.arraycopy(accountNo, accountNo.length - 13, accountNoPart,
470+
20, 12);
471+
} else {
463472
//不含最后一位校验位,不足12位左补0
464473
byte[] temp = new byte[12];
465-
for (int i = 0; i < 12; i++)
474+
for (int i = 0; i < 12; i++) {
466475
temp[i] = '0';
476+
}
467477
System.arraycopy(accountNo, 0, temp, 12-accountNo.length, accountNo.length);
468478

469479
System.arraycopy(temp, 0, accountNoPart, 20, temp.length);
@@ -594,10 +604,8 @@ public static String decryptPass(byte[] key,String accountNo,byte[] pass){
594604
* ����PIN
595605
* @param pinFmt ����PINBLOCK�㷨 0-ΪANSI X9.8 1-ISO 9564-1 //2-IBM3624
596606
* @param keyValue ��Կֵ
597-
* @param raw ����ܵ����
598-
* @param initIV ��ʼ����������CBC���ܣ���Ϊ��Ĭ��Ϊ0
599607
* @return byte[] ���ܺ�����
600-
* @throws util.EncryptException
608+
* @throws EncryptException
601609
*/
602610
public static byte[] encryptPIN(byte pinFmt, byte[] keyValue,
603611
byte[] accountNo, byte[] pin) throws EncryptException
@@ -606,9 +614,10 @@ public static byte[] encryptPIN(byte pinFmt, byte[] keyValue,
606614
throw new EncryptException(
607615
"encryptPIN key value cann't is null exception.");
608616
}
609-
if (pin == null || pin.equals(""))
617+
if (pin == null || pin.equals("")) {
610618
throw new EncryptException(
611619
"encryptPIN pin cann't is null exception.");
620+
}
612621
try
613622
{
614623
byte[] pinBlock;

fast-common/src/main/java/com/j2eefast/common/core/crypto/EnctryptTools.java

+22-46
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,9 @@ public static String ccbXorMac(byte[] macStr, byte[] macKye) throws Exception{
6969
byte[] tempBuf = new byte[8];
7070
System.arraycopy(block.getBytes(),0,tempBuf,0,8);
7171
byte mode = 0;
72-
if(macKye.length == 16)
73-
mode = 2;
72+
if(macKye.length == 16) {
73+
mode = 2;
74+
}
7475
res = EncryptUtil.doEncrypt(mode, macKye, tempBuf, null);
7576

7677
/**将加密后的结果与后8 个字节异或*/
@@ -103,7 +104,7 @@ public static String ccbXorMac(byte[] macStr, byte[] macKye) throws Exception{
103104
/// <param name="key">密钥</param>
104105
/// <param name="data">数据</param>
105106
/// <returns>16进制MAC值</returns>
106-
public static String StpMac(byte[] data, byte[] keyValue) throws Exception{
107+
public static String stpMac(byte[] data, byte[] keyValue) throws Exception{
107108
//把报文以8字节分组,最后一组不足8字节补0,
108109
int datalen = data.length;
109110
datalen += (8 - datalen % 8) % 8; //不足8位不足8位
@@ -191,9 +192,9 @@ public static String eviXorMac(byte[] macStr, byte[] macKye) throws Exception{
191192
/**将运算后的结果(ENC BLOCK2)转换成16 个HEXDECIMAL 取前16个字节作为MAC值*/
192193
return HexUtil.bytesToHexStr(mes, 0, 8).toUpperCase();
193194
}
194-
195+
195196
/**
196-
*
197+
*
197198
* 兴业前置SM4MAC计算方法
198199
* @author zhouzhou Email:[email protected]
199200
* @date Aug 21, 2018
@@ -203,8 +204,7 @@ public static String eviXorMac(byte[] macStr, byte[] macKye) throws Exception{
203204
* @return
204205
*
205206
*/
206-
public static byte[] posSM4Mac(byte[] keyValue, byte[] data)
207-
{
207+
public static byte[] posSm4Mac(byte[] keyValue, byte[] data){
208208
//把报文以8字节分组,最后一组不足8字节补0,
209209
//byte[] data = Encoding.Default.GetBytes(mac);
210210
int datalen = data.length;
@@ -230,27 +230,21 @@ public static byte[] posSM4Mac(byte[] keyValue, byte[] data)
230230
{
231231
for (int j = 0; j < 16; j++)
232232
{
233-
// DESEncrypt0(secdata[i * 8 + j], key1);
234233
temp[j] = secdata[i * 16 + j];
235234
temp[j] ^= res[j];
236235
}
237-
//res = Encrypt(temp, key1);
238-
// res = SM4.EncriptB(temp, keyValue);
239236
SM4.GMSM4(temp, temp.length, keyValue, res, SM4.ENCRYPT);
240-
//res = convertHexStrToByteArray(Encrypt3Des(convertByteArrayToHexStr(res), key));
241237
}
242-
//res = Decrypt(res, key2);
243-
//res = Encrypt(res, key1);
244238
return HexUtil.bytesToHexStr(res, 0, 4).toUpperCase().getBytes();
245239
}
246240

247241

248242
public static String SM4Mac(byte[] keyValue, byte[] data)
249243
{
250244
//把报文以8字节分组,最后一组不足8字节补0,
251-
//byte[] data = Encoding.Default.GetBytes(mac);
252245
int datalen = data.length;
253-
datalen += (16 - datalen % 16) % 16; //不足16位不足16位
246+
//不足16位不足16位
247+
datalen += (16 - datalen % 16) % 16;
254248
byte[] secdata = new byte[datalen];
255249
System.arraycopy(data, 0, secdata, 0, data.length);
256250
for (int i = data.length; i < datalen; i++)
@@ -260,8 +254,6 @@ public static String SM4Mac(byte[] keyValue, byte[] data)
260254
byte[] res = new byte[16];
261255
byte[] temp = new byte[16];
262256

263-
//yte[] key1 = new byte[8];
264-
//byte[] key2 = new byte[8];
265257

266258
//Array.Copy(keyValue, 0, key1, 0, key1.Length); //左部分
267259
//Array.Copy(keyValue, 8, key2, 0, key1.Length); //右部分
@@ -276,13 +268,8 @@ public static String SM4Mac(byte[] keyValue, byte[] data)
276268
temp[j] = secdata[i * 16 + j];
277269
temp[j] ^= res[j];
278270
}
279-
//res = Encrypt(temp, key1);
280-
// res = SM4.EncriptB(temp, keyValue);
281271
SM4.GMSM4(temp, temp.length, keyValue, res, SM4.ENCRYPT);
282-
//res = convertHexStrToByteArray(Encrypt3Des(convertByteArrayToHexStr(res), key));
283272
}
284-
//res = Decrypt(res, key2);
285-
//res = Encrypt(res, key1);
286273
return HexUtil.convertByteArrayToHexStr(res);
287274
}
288275

@@ -306,12 +293,14 @@ public static String DES3KKYEncrypt(byte[] key,byte[] pan,byte[] pin, int mode)
306293
if(mode >= 2) {
307294
LOG.info("Pinblock:" + HexUtil.convertByteArrayToHexStr(Pinblock));
308295
}
309-
310-
byte[] LK = new byte[8]; //可以分为LK(密钥的左边8字节),
296+
//可以分为LK(密钥的左边8字节)
297+
byte[] LK = new byte[8];
311298
System.arraycopy(key, 0, LK, 0, 8);
312-
byte[] CK = new byte[8]; //CK(密钥的中间8字节)
299+
//CK(密钥的中间8字节)
300+
byte[] CK = new byte[8];
313301
System.arraycopy(key, 8, CK, 0, 8);
314-
byte[] RK = new byte[8];//RK(密钥的左边8字节)
302+
//RK(密钥的左边8字节)
303+
byte[] RK = new byte[8];
315304
System.arraycopy(key, 16, RK, 0, 8);
316305
/**
317306
只是第一次计算,使用密钥LK;第二次计算,使用密钥CK;第三次计算,使用密钥LK。基本过程如下:
@@ -343,12 +332,12 @@ public static String DES3KKYEncrypt(byte[] key,byte[] pan,byte[] pin, int mode)
343332
* @return
344333
*
345334
*/
346-
public static String StpSM4Mac(byte[] data,byte[] keyValue)
335+
public static String stpSm4Mac(byte[] data,byte[] keyValue)
347336
{
348337
//把报文以8字节分组,最后一组不足8字节补0,
349-
//byte[] data = Encoding.Default.GetBytes(mac);
350338
int datalen = data.length;
351-
datalen += (16 - datalen % 16) % 16; //不足16位不足16位
339+
//不足16位不足16位
340+
datalen += (16 - datalen % 16) % 16;
352341
byte[] secdata = new byte[datalen];
353342
System.arraycopy(data, 0, secdata, 0, data.length);
354343
for (int i = data.length; i < datalen; i++)
@@ -358,29 +347,18 @@ public static String StpSM4Mac(byte[] data,byte[] keyValue)
358347
byte[] res = new byte[16];
359348
byte[] temp = new byte[16];
360349

361-
//yte[] key1 = new byte[8];
362-
//byte[] key2 = new byte[8];
363-
364-
//Array.Copy(keyValue, 0, key1, 0, key1.Length); //左部分
365-
//Array.Copy(keyValue, 8, key2, 0, key1.Length); //右部分
366350

367351
/**按每8个字节做异或 **/
368352
int arrayLen = datalen / 16;
369353
for (int i = 0; i < arrayLen; i++)
370354
{
371355
for (int j = 0; j < 16; j++)
372356
{
373-
// DESEncrypt0(secdata[i * 8 + j], key1);
374357
temp[j] = secdata[i * 16 + j];
375358
temp[j] ^= res[j];
376359
}
377-
//res = Encrypt(temp, key1);
378-
// res = SM4.EncriptB(temp, keyValue);
379360
SM4.GMSM4(temp, temp.length, keyValue, res, SM4.ENCRYPT);
380-
//res = convertHexStrToByteArray(Encrypt3Des(convertByteArrayToHexStr(res), key));
381361
}
382-
//res = Decrypt(res, key2);
383-
//res = Encrypt(res, key1);
384362
return HexUtil.bytesToHexStr(res, 0, 8).toUpperCase();
385363
}
386364

@@ -399,7 +377,6 @@ public static String StpSM4Mac(byte[] data,byte[] keyValue)
399377
*/
400378
public static byte[] encryptSM4Pass(byte[] key, String cardNo, String PIN){
401379
byte[] pinBlok = EncryptUtil.formatSM4Pinblock(cardNo.getBytes(), PIN.getBytes());
402-
//LOG.info("SM4Pinblock:" + HexUtil.convertByteArrayToHexStr(pinBlok));
403380
byte[] out = new byte[16];
404381
SM4.GMSM4(pinBlok, pinBlok.length, key, out, SM4.ENCRYPT);
405382
return out;
@@ -441,7 +418,6 @@ public static String WekDecryptPass(byte[] key, String cardNo, String PIN) throw
441418
LOG.info("Pinblock:" + HexUtil.convertByteArrayToHexStr(pinBlok));
442419
//2.加密
443420
byte[] pinm = EncryptUtil.doEncrypt(EncryptConst.DECRY_3DES_CBC, key, pinBlok, null);
444-
445421
//3.转换16进制
446422
return HexUtil.convertByteArrayToHexStr(pinm);
447423
}
@@ -455,9 +431,9 @@ public static String WekDecryptPass(byte[] key, String cardNo, String PIN) throw
455431
* @throws Exception
456432
*/
457433
public static String DesDecode(String str,String key) throws Exception{
458-
//
459434
int datalen = key.getBytes().length;
460-
datalen += (16 - datalen % 16) % 16; //不足16位不足16位
435+
//不足16位不足16位
436+
datalen += (16 - datalen % 16) % 16;
461437
byte[] secdata = new byte[datalen];
462438
System.arraycopy(key.getBytes(), 0, secdata, 0, key.getBytes().length);
463439
for (int i = key.getBytes().length; i < datalen; i++)
@@ -494,9 +470,9 @@ public static String DesDecode(String str,String key) throws Exception{
494470
* @throws Exception
495471
*/
496472
public static String SM4Decode(String str,String key) throws Exception{
497-
//
498473
int datalen = key.getBytes().length;
499-
datalen += (16 - datalen % 16) % 16; //不足16位不足16位
474+
//不足16位不足16位
475+
datalen += (16 - datalen % 16) % 16;
500476
byte[] secdata = new byte[datalen];
501477
System.arraycopy(key.getBytes(), 0, secdata, 0, key.getBytes().length);
502478
for (int i = key.getBytes().length; i < datalen; i++)

0 commit comments

Comments
 (0)