JavaCard Applet Development Related Questions and Answers.
-
setayesh
- Posts: 4
- Joined: Tue Oct 27, 2015 8:53 am
- Points :0
-
Contact:
Post
by setayesh » Wed Oct 28, 2015 4:20 pm
My master gave me a smart card and a card reader with a Java application.
And I have a week to explain how to read and write on the card, while I am a beginner programmers in Java
Who can help me? Is there a book or an article about this topic?
I've downloaded some paper, but nobody did not explain how to write on the smart card.
Please help me , thanks in advance .
-
mabel
- Posts: 237
- Joined: Mon May 18, 2015 3:09 am
- Points :1705
-
Contact:
Post
by mabel » Mon Nov 02, 2015 2:36 am
I use
JCIDE to build my applet and
JCIDE shall generate the CAP file automatically under the project path(e.g. C:\workspace\test\bin\patest\javacard) if your project is built successfully.
So if you just want to get the CAP file, just create a project in
JCIDE , paste you applet code and build your project, then you can get your CAP file.
-
Tolice
- Posts: 40
- Joined: Wed May 20, 2015 2:41 am
- Points :254
-
Contact:
Post
by Tolice » Mon Nov 02, 2015 3:53 am
Download Cap error: Check Card Cryptogram failed.
You can switch to the BaseAPDU page in output, view the APDU while downloading cap file.
Maybe the key of this card you used is changed, you can check if the key is the default "404142434445464748494A4B4C4D4E4F".
-
setayesh
- Posts: 4
- Joined: Tue Oct 27, 2015 8:53 am
- Points :0
-
Contact:
Post
by setayesh » Mon Nov 16, 2015 3:32 am
mabel wrote:I use
JCIDE to build my applet and
JCIDE shall generate the CAP file automatically under the project path(e.g. C:\workspace\test\bin\patest\javacard) if your project is built successfully.
So if you just want to get the CAP file, just create a project in
JCIDE , paste you applet code and build your project, then you can get your CAP file.
tnx for reply
when i paste my program , it has 44 errors :.
like that
C:\WORKSP~1\new\src\com\netrise\sc\SmartCard.java:4: package javax.smartcardio does not exist
and i cant find this package.
when i merge all packages , it has one error .
like that
error: cannot read: ByteUtil.java
-
setayesh
- Posts: 4
- Joined: Tue Oct 27, 2015 8:53 am
- Points :0
-
Contact:
Post
by setayesh » Mon Nov 16, 2015 3:38 am
And this is ByteUtil :
Code: Select all
package com.netrise.util;
import java.io.UnsupportedEncodingException;
public class ByteUtil {
public static byte[] extract(byte[] data, int start, int length) {
byte[] result = new byte[length];
int pointer = 0;
for (int i = 0; i < data.length; i++) {
byte b = data[i];
if (i >= start && i < start + length) {
result[pointer] = b;
pointer++;
}
}
return result;
}
public static String arrayToHex(byte[] data) {
StringBuffer sb = new StringBuffer();
for (int i = 0; i < data.length; i++) {
String bs = Integer.toHexString(data[i] & 0xFF);
if (bs.length() == 1) {
sb.append(0);
}
sb.append(bs);
}
return sb.toString();
}
public static byte[] AsciiStringToBytes(String text) {
if (text == null || text.length() < 1) {
return new byte[0];
}
return text.getBytes();
}
public static String BytesToAsciiString(byte[] Data) {
try {
String s = new String(Data, 0 , Data.length , "ASCII");
return s;
}
catch(UnsupportedEncodingException e) {
e.printStackTrace();
}
return " ";
}
public static byte[] UTF16StringToBytes(String text) {
byte[] buff;
try {
buff = text.getBytes("UTF-16");
}
catch(UnsupportedEncodingException e) {
System.out.println(e.getMessage());
buff = null;
}
return buff;
}
public static String BytesToUTF16String(byte[] Bytes) {
try {
String s = new String(Bytes, 0 , Bytes.length , "UTF-16");
return s;
}
catch(UnsupportedEncodingException e) {
e.printStackTrace();
}
return null;
}
public static byte[] UTF8StringToBytes(String text) {
if (text == null || text.length() < 1) {
return new byte[0];
}
byte[] buff;
try {
buff = text.getBytes("UTF-8");
}
catch(UnsupportedEncodingException e) {
e.printStackTrace();
buff = null;
}
return buff;
}
public static String BytesToUTF8String(byte[] Bytes) {
try {
String s = new String(Bytes, 0 , Bytes.length , "UTF-8");
return s;
}
catch(UnsupportedEncodingException e) {
e.printStackTrace();
}
return null;
}
public static byte[] resizeArray(byte[] oldArray, int newSize) {
int oldSize = oldArray.length;
byte[] newArray = new byte[newSize];
int preserveLength = Math.min(oldSize, newSize);
if (preserveLength > 0) {
System.arraycopy(oldArray, 0, newArray, 0, preserveLength);
}
return newArray;
}
public static byte[] resizeArray(Object[] oldArray, int newSize) {
int oldSize = oldArray.length;
byte[] newArray = new byte[newSize];
int preserveLength = Math.min(oldSize, newSize);
if (preserveLength > 0) {
System.arraycopy(oldArray, 0, newArray, 0, preserveLength);
}
return newArray;
}
}
Users browsing this forum: No registered users and 40 guests
JavaCard OS : Disclaimer
Board Disclaimer
The views and comments posted in these fora are personal and do not necessarily represent the those of the Management of JavaCard OS.
The Management of JavaCard OS does not, under any circumstances whatsoever, accept any responsibility for any advice, or recommentations, made by, or implied by, any member or guest vistor of JavaCard OS that results in any loss whatsoever in any manner to a member of JavaCard OS, or to any other person.
Furthermore, the Management of JavaCard OS is not, and cannot be, responsible for the content of any other Internet site(s) that have been linked to from JavaCard OS.