Search code examples
javasmartcardsmartcard-reader

Reading data from SLE 4442 smart card using ACR38 Card Reader


Am working on a project to read from and write data to SLE 4442 smart cards. The Card Reader am using is ACR38 from ACS. Following their APDU commands, I have being able to get access to the card and read some data. But am suspecting that I still have not being able to read the exact data inside. This is because, anytime my application is started, it brings out new data. I really don't know why is behaving that way, can somebody please spot where am getting wrong here? Below is my Java code:

CardChannel channel = card.getBasicChannel(); byte[] read_memory_card = {(byte) 0xFF, (byte) 0xB0, (byte) 0xA7A6A5A4, (byte) 0xA3A2A1A0, (byte) 0x00}; ResponseAPDU read_data_resp = channel.transmit(new CommandAPDU(read_memory_card)); if (read_data_resp.getSW1() == 0x90 && read_data_resp.getSW2() == 0x00) { System.out.println("Data in Card: " + read_data_resp.getData() + "and SW1: " + read_data_resp.getSW1()); }

What I get as a result:
Data in Card: [B@378bf509 and SW1: 144

Please note that Data in Card changes every time, the application is restarted.


Solution

  • I'm assuming that you seeing "different" data isn't so much that it is truly different but rather you are printing out the pointer in memory that Java uses as a default toString(). I can only assume that read_data_resp.getData() retuurns a byte[] in which case you'll want to convert each value into a string if you want to visualize it. If you search google on how to convert a byte array to a hex string you'll find lots of answers.