fixed DE55 length

This commit is contained in:
kizzy 2026-01-10 16:16:43 +07:00
parent 25ba7022da
commit 13617eead1
3 changed files with 33 additions and 8 deletions

View File

@ -0,0 +1,25 @@
package com.utsmm.kbz;
import com.utsmyanmar.baselib.util.EReceiptHelper;
import org.junit.Test;
public class GeneralTest {
@Test
public void testSignGeneration() {
String timestamp = String.valueOf(System.currentTimeMillis());
String signature = generateSignature(timestamp);
System.out.println("Timestamp: " + timestamp);
System.out.println("Signature: " + signature);
}
private static String generateSignature(String timestamp) {
String secret = "y812J21lhha11OS";
String bodyString = "{}";
String dataToHash = bodyString + secret + timestamp;
return EReceiptHelper.sha256(dataToHash);
}
}

View File

@ -237,7 +237,7 @@ public class EncodePackage {
int varValueLen;
if(entry.getKey().equals("F055")) {
varValue = Utils.StrToBCDBytes(String.format("%0" + msgField.getLengthType() + "d", msgField.getDataLength() / 2));
varValueLen = varValue.length + 1 ;
varValueLen = varValue.length ; // +1
} else {
varValue = (String.format("%0" + msgField.getLengthType() + "d", msgField.getDataLength()/2)).getBytes();
varValueLen = varValue.length;
@ -251,12 +251,12 @@ public class EncodePackage {
if(hostName == HostName.BPC ) {
if(msgField.getLengthType() == 4) {
varValue = Utils.StrToBCDBytes(String.format("%0"+msgField.getLengthType() + "d",msgField.getDataLength()));
} else {
// if(msgField.getLengthType() == 4) {
// varValue = Utils.StrToBCDBytes(String.format("%0"+msgField.getLengthType() + "d",msgField.getDataLength()));
// } else {
//
// }
varValue = (String.format("%0" + msgField.getLengthType() + "d", msgField.getDataLength()/2)).getBytes();
}
} else {
varValue = Utils.StrToBCDBytes(String.format("%0"+msgField.getLengthType() + "d",msgField.getDataLength()));
}

View File

@ -108,7 +108,7 @@ public class FieldConfig {
/* FLD 53 */ {2, SDK_8583_LEN_ASC, 32, SDK_8583_DATA_BCD, SDK_8583_ALIGN_L, '0'},
/* FLD 54 */ {3, SDK_8583_LEN_BCD, 40, SDK_8583_DATA_ASC, SDK_8583_ALIGN_L, ' '},
/* FLD 55 */ {3, SDK_8583_LEN_ASC, 255, SDK_8583_DATA_BIT, SDK_8583_ALIGN_L, '0'},
/* FLD 55 */ {2, SDK_8583_LEN_ASC, 255, SDK_8583_DATA_BIT, SDK_8583_ALIGN_L, '0'},
// /* FLD 55 */ {4, SDK_8583_LEN_BCD, 255, SDK_8583_DATA_BIT, SDK_8583_ALIGN_L, '0'},
/* FLD 56 */ {0, SDK_8583_LEN_BCD, 12, SDK_8583_DATA_BCD, SDK_8583_ALIGN_R, '0'},