Question

I have written an applet and installed it in smart card. But I don't know how to read and write data to smart card?

private void readName(APDU apdu) throws ISOException
{
    byte[] apduBuffer = apdu.getBuffer();
    for (byte i=0; i<userName.length; i++)
    {
        apduBuffer[5+i] = userName[(byte)i] ;
    }
    apdu.setOutgoing();
    apdu.setOutgoingLength((short)userName.length);
    apdu.sendBytes((short)5, (short)userName.length);
}

Is it right code to read data from smart card?

please tell me how to write data to smart card using javacard.

Was it helpful?

Solution 2

I found solution.actually I am using eclipse as a editor java card plugin are install in it.when I run program on Smart Card it install latest applet on previous applet every time.To see result we can use pyapdu tool it is very good. thanks for all the response..

OTHER TIPS

Your card is either contact or contactless. Since you say you have already installed the applet, I assume you have the keys to the card.

If so, in order to communicate with your card you will need to do the following:

  1. First authenticate with the Security Domain to which the applet is installed
  2. Select the AID of the applet
  3. use SEND to send data to applet.

And in the response, you will see the bytes you are sending from the Applet:

apdu.setOutgoingLength((short)userName.length);
apdu.sendBytes((short)5, (short)userName.length);

If you need anything more, you will need to provide more details on what you are attempting to accomplish.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top