How to Store a String data into the Java Card
How to Store a String data into the Java Card
I need to know how to store String data in my JavaCard、any help please
Re: How to Store a String data into the Java Card
On PC,convert String to byte stream, and transitive to card. Store byte stream with a byte array object.
1,PC : String —-> byte stream. ——-> Card
2.Card: byte stream ——> PC
3. PC : byte stream ——>String
1,PC : String —-> byte stream. ——-> Card
2.Card: byte stream ——> PC
3. PC : byte stream ——>String
well
Re: How to Store a String data into the Java Card
On PC
On card
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;
well
Re: How to Store a String data into the Java Card
Javacard has string class. You may consider your need carefully.
Re: How to Store a String data into the Java Card
Javacard has string class,that's true. But it didn't support by most cards in the market.
well
Who is online
Users browsing this forum: No registered users and 33 guests