How to Store a String data into the Java Card
Posted: Fri Feb 22, 2019 10:48 pm
I need to know how to store String data in my JavaCard、any help please
JavaCardOS - JavaCardForum
https://www.javacardos.com/javacardforum/
https://www.javacardos.com/javacardforum/viewtopic.php?f=15&t=2004
Code: Select all
public static void main(String[] arguments) {
String sss = "string to byte stream";
byte[] byte_stream = sss.getBytes();
// send byte_stream to card
// do the transmit procession
// receive byte_steam from card ;
String recovery = new String(byte_stream);
System.out.println(recovery);
}
Code: Select all
case (byte)INS_SEND_RECV_APDU_1:
//Define a byte string
byte sendStr[] = {'A','P','D','U', ',', 'C','l','a','s','s', ',', 'D','e','m','o'};
short len = (short) sendStr.length;
//Copy character to APDU Buffer.
Util.arrayCopyNonAtomic(sendStr, (short)0, buf, (short)0, (short)len);
//Send the 'sendStr' string, the hex of JCRE sending data is the ASCII of sendStr.
apdu.setOutgoingAndSend((short)0, (short)len);
break;