Итак, у меня есть бесконтактная карта Mastercard и телефон Visa Paywave. Я использую бесконтактный HID Omnikey 5427 CK.PSE карты не то, что должно быть
Это мой код: `
static boolean cardReading = true;
public static void main(String[] args) throws CardException, UnsupportedEncodingException {
while (cardReading == true) {
try {
TerminalFactory factory = TerminalFactory.getDefault();
List<CardTerminal> terminals = factory.terminals().list();
CardTerminal terminal = terminals.get(0);
if (!terminal.isCardPresent()) {
continue;
}
System.out.println("Terminals: " + terminals);
System.out.println("Used terminal: " + terminal);
Card card = terminal.connect("T=0");
System.out.println("\n\nInserted card: " + card);
CardChannel channel = card.getBasicChannel();
String pse = "00A404000E325041592E5359532E444446303100";
CommandAPDU apdu = new CommandAPDU(pse.getBytes());
ResponseAPDU r = channel.transmit(apdu);
System.out.println("Response: " + toHex(r.getData().toString()) + " " + r);
System.out.println("ADPU: " + toHex(apdu.getBytes().toString()) + " " + r.getSW() + " " + r.getSW1() + " " + r.getSW2() + " " + r.getNr());
apdu = new CommandAPDU((byte)0x00, (byte)0xB2, (byte)0x01, (byte)0x0C, (byte)0x00);
r = channel.transmit(apdu);
cardReading = false;
Toolkit.getDefaultToolkit().beep();
System.out.println("Terminals: " + terminals);
System.out.println("Used terminal: " + terminal);
System.out.println("\n\nInserted card: " + card);
System.out.println("Response: " + toHex(r.getData().toString()) + " " + r);
System.out.println("ADPU: " + toHex(apdu.getBytes().toString()) + " " + r.getSW() + " " + r.getSW1() + " " + r.getSW2() + " " + r.getNr());
System.exit(1);
} catch(Exception e) {
continue;
}
}
}
public static byte[] hexStringToByteArray(String s) {
int len = s.length();
byte[] data = new byte[len/2];
for (int i = 0; i < len; i += 2) {
data[i/2] = (byte) ((Character.digit(s.charAt(i), 16) << 4)
+ Character.digit(s.charAt(i+1), 16));
}
return data;
}
public static String toHex(String arg) {
return String.format("%040x", new BigInteger(1, arg.getBytes()));
}
`
И поэтому выход:
Terminals: [PC/SC terminal HID OMNIKEY 5427 CK 0]
Used terminal: PC/SC terminal HID OMNIKEY 5427 CK 0
Inserted card: PC/SC card in HID OMNIKEY 5427 CK 0, protocol T=0, state OK
Response: 0000000000000000005b42403163343630306630 ResponseAPDU: 65 bytes, SW=9000
ADPU: 000000000000000000005b424035623665663230 36864 144 0 63
Terminals: [PC/SC terminal HID OMNIKEY 5427 CK 0]
Used terminal: PC/SC terminal HID OMNIKEY 5427 CK 0
Inserted card: PC/SC card in HID OMNIKEY 5427 CK 0, protocol T=0, state OK
Response: 0000000000000000005b42403565616235383039 ResponseAPDU: 14 bytes, SW=9000
ADPU: 0000000000000000005b42403433323065373664 36864 144 0 12
Я не понимаю, почему это ответ 0000000000000000005b42403565616235383039 ... Пожалуйста, помогите ,
С уважением, Влад.
Какой ответ вы ожидаете? Что не работает? Просьба уточнить. –
@JimGarrison Люди обычно получают что-то вроде этого в ответ: 6F2F840E325041592E5359532E4444463031A51DBF0C1A61184F07A0000000031010500A564953412044454249548701019000 –
В него входит AID или еще что-то. –