Page 1 of 1

How to send int

Posted: Sun Jun 18, 2017 10:52 pm
by Neqikoo
In my applet, there are some int variable. And I want to send these int variable. But I don't know how. How can I send int variable?

I only know how to send bytes.

Code: Select all

private void mySend(APDU apdu) {
          byte[] buffer = apdu.getBuffer();     
          apdu.setOutgoing();
          short totalBytes = (short) out.length;
          apdu.setOutgoingLength(totalBytes);
          apdu.sendBytesLong(out, (short) 0, (short) out.length);
        }

Re: How to send int

Posted: Mon Jun 19, 2017 2:11 am
by Crawford
You can convert int to byte[] to solve your problem.
To convert an int to a byte array, keep in mind that an int is 4 bytes. Then this is a straight Java problem that is not specific to Java Card.