如何使用java卡apdu从智能卡写入和读取数据
我写了一个小程序并将其安装在智能卡中。但我不知道如何读写智能卡数据?
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 将数据写入智能卡。
I have written an applet and installed it in smart card. But I don't know how to read and write data to smart card?
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);
}
Is it right code to read data from smart card?
please tell me how to write data to smart card using javacard.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您的卡可以是接触式的,也可以是非接触式的。既然你说你已经安装了小程序,我假设你有卡的密钥。
如果是这样,为了与您的卡进行通信,您需要执行以下操作:
在响应中,您将看到从 Applet 发送的字节:
如果您需要更多内容,您将需要提供有关您尝试完成的任务的更多详细信息。
Your card is either contact or contactless. Since you say you have already installed the applet, I assume you have the keys to the card.
If so, in order to communicate with your card you will need to do the following:
And in the response, you will see the bytes you are sending from the Applet:
If you need anything more, you will need to provide more details on what you are attempting to accomplish.
我找到了解决方案。实际上,我使用 eclipse 作为编辑器,其中安装了 java 卡插件。当我在智能卡上运行程序时,它每次都会在以前的小程序上安装最新的小程序。要查看结果,我们可以使用 pyapdu 工具,它非常好。感谢所有的回复..
I found solution.actually I am using eclipse as a editor java card plugin are install in it.when I run program on Smart Card it install latest applet on previous applet every time.To see result we can use pyapdu tool it is very good. thanks for all the response..