我编写了一个applet并将其安装在智能卡中。但是我不知道如何在智能卡上读写数据?
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);
}
从智能卡读取数据是正确的代码吗?
请告诉我如何使用javacard向智能卡写入数据
您的卡是接触式的还是非接触式的。既然您说您已经安装了applet,那么我假定您有卡的钥匙。
如果是这样,为了与您的卡通信,您需要做以下操作:
- 首先使用安装了小程序的安全域进行身份验证
- 选择小程序的AID
- 使用SEND向applet发送数据
在响应中,您将看到您从Applet发送的字节:
apdu.setOutgoingLength((short)userName.length);
apdu.sendBytes((short)5, (short)userName.length);
如果你需要更多的东西,你需要提供更多的细节,你试图完成什么
我找到解决办法了。实际上我是使用eclipse作为编辑器java卡插件安装在它。当我在智能卡上运行程序时,它每次都会在以前的小程序上安装最新的小程序。要查看结果我们可以使用pyapdu工具,它是非常好的。感谢大家的回复