만 (바이트 배열) 진수 문자열로 진수 바이트를 변환 할 경우, 다음과 같은 코드를 사용할 수 있습니다 처리 :
static byte[] output = new byte[10];
static short[] input = new short[4];
// the weights table for hex byte: 256^1 = 256, 256^2 = 65536, and 256^3 = 16777216
// 256^0 is moved outside the table for optimization (assigned as initial result value)
public static byte[] weight = {
6, 6, 6,
1, 3, 5,
2, 5, 2,
7, 5, 0,
7, 6, 0,
7, 0, 0,
6, 0, 0,
1, 0, 0,
0, 0, 0,
0, 0, 0
};
// the method to convert 4 bytes of hex into decimal string (10 byte arrays)
// final result is stored in output byte array
public static void convertHexToDecimalString(byte[] hex) {
// convert input to positive (byte array to short array)
for (byte i = 0; i < 4; i++) {
input[i] = (short) (hex[i] & 0x00FF);
}
// assign the least significant hex byte to result
short result = input[3];
byte offset = 0;
// loop to calculate and assign each decimal digit
for (byte i = 0; i < 10; i++) {
result = (short) ((weight[offset] * input[0])
+ (weight[offset + 1] * input[1])
+ (weight[offset + 2] * input[2]) + result);
output[9 - i] = (byte) (0x30 + result % 10);
result /= 10;
offset += 3;
}
}
옵션은 Java Card가'int' 타입을 지원할 수도 있고 지원하지 않을 수도 있음을 의미합니다. int가 필요한 경우이를 지원하는 올바른 카드를 구입해야합니다. – Robert