我如何在卡上贷记或借记超过1个字节? [英] How can i credit or debit more than 1 byte to/from card?

查看:121
本文介绍了我如何在卡上贷记或借记超过1个字节?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是新手小程序,我通过以下链接使用过:使用Java卡
电子钱包
,用于创建电子钱包项目。
我以前可以通过以下命令来刷卡: 80 30 00 00 01 1A 00

I am newbie applets and i used from this link: working with Java Card Wallet for creating an Wallet project. I before could credit card amount by this command : 80 30 00 00 01 1A 00.

我现在想在当前金额中添加 5000。如您所知,十六进制的5000等于

I now want add '5000' to the present amount. As you know 5000 in hex equals

,其中'1388'是2个字节。所以我必须发送2字节数据13和88到卡。

with '1388' that is 2 byte. So i must send 2 byte data 13 and 88 to the card.

我创建了波纹管命令并将其发送到卡上,但是我得到了 67 00错误长度作为

I create bellow command and sent it to card but i get '67 00 Wrong lenght' as

响应。

80 30 00 00 02 13 88 00

我如何在卡上贷记或借记超过1个字节?

How can i credit or debit more than 1 byte to/from card?

推荐答案

您必须更改您指向的Applet的代码:

You'll have to change the code of the Applet you're pointing to of course:

if ((numBytes != 1) || (byteRead != 1)) {
    ISOException.throwIt(ISO7816.SW_WRONG_LENGTH); // constant with value 0x6700
}

因此必须确保它允许2要发送的字节,则可以使用 Util.getShort 方法将字节转换为16位带符号的值(通常使用大尾数二补码表示法)。

So you must make sure that it allows for 2 bytes to be send, then you can use the Util.getShort method to convert to the bytes to a 16 bit signed value (using big endian two complement notation, as usual).

这篇关于我如何在卡上贷记或借记超过1个字节?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆