如何使用java卡向智能卡写入数据?举例说明
有人可以告诉我如何使用java卡在智能卡中写入数据吗? 我有这个代码 我正在使用java卡2.2
private void writeName(APDU apdu) throws ISOException
{
apdu.setIncomingAndReceive();
byte[] apduBuffer = apdu.getBuffer();
byte j = (byte)apduBuffer[4];
userName = new byte[j];
for (byte i=0; i<j; i++)
{
userName[(byte)i] = (byte)apduBuffer[5+i];
}
}
can some one tell me how to write data in smart card using java card?
i have this code
i am using java card 2.2
private void writeName(APDU apdu) throws ISOException
{
apdu.setIncomingAndReceive();
byte[] apduBuffer = apdu.getBuffer();
byte j = (byte)apduBuffer[4];
userName = new byte[j];
for (byte i=0; i<j; i++)
{
userName[(byte)i] = (byte)apduBuffer[5+i];
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您使用 JCOP 插件来开发 Applet,您可以在 bin/ 目录中看到每个包的 .CAP 文件。现在您需要按照依赖关系的顺序安装每个包。假设您的应用程序由包 A、B 和 C 组成,而您的小程序位于 C 包中。 B 导入 A,C 导入 B。
您需要安装软件包的顺序是 A、B、C。使用 JCOP,可以通过以下方式完成此操作:
一旦对三个软件包完成了此操作,您将需要安装小程序。这可以通过以下方式完成:
一旦执行此操作,您将看到小程序处于 SELECTABLE 状态。您的 JCOP shell 控制台将如下所示:
所有这些“模块”(库)包都显示如下:
所有处于 SELECTABLE 状态的小程序现在都可以被选择并与之交互。如果您想使用 A00000008710015553 向 Applet 发送数据,则需要先选择它。交互如下图:
现在,您可以使用send 命令向上述Applet 发送数据:
这些都是标准的GP 命令。我假设您使用的是 GP 兼容卡;不过你什么也没提到。
我个人认为,在进一步深入研究之前,您需要仔细阅读一下 JC 运行时环境和 JC VM 的工作原理以及它与 API 和一些 GP 规范的关系。
If you are using JCOP plugin for developing the Applet, you can see .CAP files in the bin/ directory for each package. Now you will need to install each package in order of dependency. Suppose your application consists of packages A, B and C with your applet in C package. And B imports A and C imports B.
The order in which you will need to install the packages are A,B,C. Using JCOP, this can be accomplished by:
Once you have done this for the three packages, you will need to install the applet. This can be accomplished by:
Once you do this you will see the applet in SELECTABLE state. Your JCOP shell console would look like :
And all those packages that are "modules" (libraries) are shown like this:
All those applets ini SELECTABLE state can now be selected and interacted with. If you want to send data to Applet with A00000008710015553, you will need to first select it. The interaction would be as shown below:
Now, you can send data to the above Applet by using send command:
These are all standard GP commands. I assumed that you are using a GP compliant card; you have mentioned nothing about it though.
I personally feel you will need to read through a bit on how JC Runtime Environment and JC VM works and it's relation with the API and a bit of GP spec before you delve into further.