How to read and write value into smart card
Posted: Wed Dec 23, 2015 5:06 am
I bought IFD R502 smart card reader which came with two A40CR cards. And I am trying to write my own applet and load it into my cards. But I have some questions.
As you see below, add method adds 5 units to a declared variable. I would like to save the variable value into the card after making an operation. Does anyone know how can i write that value into the card? And if possible, how can i read it?
As you see below, add method adds 5 units to a declared variable. I would like to save the variable value into the card after making an operation. Does anyone know how can i write that value into the card? And if possible, how can i read it?
Code: Select all
byte[] buffer = apdu.getBuffer();
byte CLA = (byte) (buffer[ISO7816.OFFSET_CLA] & 0xFF);
byte INS = (byte) (buffer[ISO7816.OFFSET_INS] & 0xFF);
if (CLA != DE_CLA){
ISOException.throwIt(ISO7816.SW_CLA_NOT_SUPPORTED);
}
switch (INS) {
case DE_INS_ADD:
add(apdu);
break;
default:
ISOException.throwIt(ISO7816.SW_INS_NOT_SUPPORTED);
}