APDU指令学习:如何读取NFC手机钱包的余额
2012-06-28 17:16
337 查看
// select PSF (1PAY.SYS.DDF01)
/*--------------------------------------------------------------*/
beijing.Util.log("select file: tag.selectByName(DFN_PSE)");
if (tag.selectByName(DFN_PSE).isOkey()) {
protected final static byte[] DFN_PSE = { (byte) '1', (byte) 'P',
(byte) 'A', (byte) 'Y', (byte) '.', (byte) 'S', (byte) 'Y',
(byte) 'S', (byte) '.', (byte) 'D', (byte) 'D', (byte) 'F',
(byte) '0', (byte) '1', }; //1PAY.SYS.DDF01
name = DFN_PSE;
ByteBuffer buff = ByteBuffer.allocate(name.length + 6);
buff.put((byte) 0x00); // CLA Class
buff.put((byte) 0xA4); // INS Instruction
buff.put((byte) 0x04); // P1 Parameter 1 SELECT by NAME
buff.put((byte) 0x00); // P2 Parameter 2
buff.put((byte) name.length); // Lc
buff.put(name); buff.put((byte) 0x00); // Le
SELECT命令参考
第1部分电子钱包电子存折应用卡片规范 之
表33 SELECT 命令报文
表34 SELECT 命令引用控制参数
如果返回结果结尾是 0x9000 ,就SELECT成功
==============================================
SFI_EXTRA_LOG = 4;
// read card info file, binary (4)
/*--------------------------------------------------------------*/
INFO = tag.readBinary(SFI_EXTRA_LOG);
==============================================
SFI_EXTRA_CNT = 5;
// read card operation file, binary (5)
/*--------------------------------------------------------------*/
CNT = tag.readBinary(SFI_EXTRA_CNT);
public Response readBinary(int sfi) {
final byte[] cmd = { (byte) 0x00, // CLA Class
(byte) 0xB0, // INS Instruction
(byte) (0x00000080 | (sfi & 0x1F)), // P1 Parameter 1
(byte) 0x00, // P2 Parameter 2
(byte) 0x00, // Le
};
CNT = tag.readBinary(SFI_EXTRA_CNT);
参考:
第1部分电子钱包电子存折应用卡片规范 之
表25 READ BINARY 命令报文
==============================================
读余额之前的操作
// select Main Application
byte[] DFI_EP = { (byte) 0x10, (byte) 0x01 };
/*--------------------------------------------------------------*/
if (tag.selectByID(DFI_EP).isOkey()) {
public Response selectByID(byte[] name) {
ByteBuffer buff = ByteBuffer.allocate(name.length + 6);
buff.put((byte) 0x00); // CLA Class
buff.put((byte) 0xA4); // INS Instruction
buff.put((byte) 0x00); // P1 Parameter 1 SELECT by ID
buff.put((byte) 0x00); // P2 Parameter 2
buff.put((byte) name.length); // Lc
buff.put(name); buff.put((byte) 0x00); // Le
return new Response(transceive(buff.array()));
==============================================
读余额
CASH = tag.getBalance(true);
public Response getBalance(boolean isEP) {
final byte[] cmd = { (byte) 0x80, // CLA Class
(byte) 0x5C, // INS Instruction
(byte) 0x00, // P1 Parameter 1
(byte) (isEP ? 2 : 1), // P2 Parameter 2
(byte) 0x04, // Le
};
参考: http://blog.csdn.net/jennyvenus/article/details/4183994 //Get Balance (defined by PBOC)
80 5C 00 02 04
PBOC 第2部分(电子钱包_电子存折应用规范)
表2 命令的类别字节和指令字节
读余额(GET BALANCE)
‘80’ ‘5C’ ‘00’ ‘0X’
/*--------------------------------------------------------------*/
beijing.Util.log("select file: tag.selectByName(DFN_PSE)");
if (tag.selectByName(DFN_PSE).isOkey()) {
protected final static byte[] DFN_PSE = { (byte) '1', (byte) 'P',
(byte) 'A', (byte) 'Y', (byte) '.', (byte) 'S', (byte) 'Y',
(byte) 'S', (byte) '.', (byte) 'D', (byte) 'D', (byte) 'F',
(byte) '0', (byte) '1', }; //1PAY.SYS.DDF01
name = DFN_PSE;
ByteBuffer buff = ByteBuffer.allocate(name.length + 6);
buff.put((byte) 0x00); // CLA Class
buff.put((byte) 0xA4); // INS Instruction
buff.put((byte) 0x04); // P1 Parameter 1 SELECT by NAME
buff.put((byte) 0x00); // P2 Parameter 2
buff.put((byte) name.length); // Lc
buff.put(name); buff.put((byte) 0x00); // Le
SELECT命令参考
第1部分电子钱包电子存折应用卡片规范 之
表33 SELECT 命令报文
表34 SELECT 命令引用控制参数
如果返回结果结尾是 0x9000 ,就SELECT成功
==============================================
SFI_EXTRA_LOG = 4;
// read card info file, binary (4)
/*--------------------------------------------------------------*/
INFO = tag.readBinary(SFI_EXTRA_LOG);
==============================================
SFI_EXTRA_CNT = 5;
// read card operation file, binary (5)
/*--------------------------------------------------------------*/
CNT = tag.readBinary(SFI_EXTRA_CNT);
public Response readBinary(int sfi) {
final byte[] cmd = { (byte) 0x00, // CLA Class
(byte) 0xB0, // INS Instruction
(byte) (0x00000080 | (sfi & 0x1F)), // P1 Parameter 1
(byte) 0x00, // P2 Parameter 2
(byte) 0x00, // Le
};
CNT = tag.readBinary(SFI_EXTRA_CNT);
参考:
第1部分电子钱包电子存折应用卡片规范 之
表25 READ BINARY 命令报文
==============================================
读余额之前的操作
// select Main Application
byte[] DFI_EP = { (byte) 0x10, (byte) 0x01 };
/*--------------------------------------------------------------*/
if (tag.selectByID(DFI_EP).isOkey()) {
public Response selectByID(byte[] name) {
ByteBuffer buff = ByteBuffer.allocate(name.length + 6);
buff.put((byte) 0x00); // CLA Class
buff.put((byte) 0xA4); // INS Instruction
buff.put((byte) 0x00); // P1 Parameter 1 SELECT by ID
buff.put((byte) 0x00); // P2 Parameter 2
buff.put((byte) name.length); // Lc
buff.put(name); buff.put((byte) 0x00); // Le
return new Response(transceive(buff.array()));
==============================================
读余额
CASH = tag.getBalance(true);
public Response getBalance(boolean isEP) {
final byte[] cmd = { (byte) 0x80, // CLA Class
(byte) 0x5C, // INS Instruction
(byte) 0x00, // P1 Parameter 1
(byte) (isEP ? 2 : 1), // P2 Parameter 2
(byte) 0x04, // Le
};
参考: http://blog.csdn.net/jennyvenus/article/details/4183994 //Get Balance (defined by PBOC)
80 5C 00 02 04
PBOC 第2部分(电子钱包_电子存折应用规范)
表2 命令的类别字节和指令字节
读余额(GET BALANCE)
‘80’ ‘5C’ ‘00’ ‘0X’
相关文章推荐
- [转]android点滴之NFC手机如何轻松读取银行卡信息?
- 装饰者模式的学习(c#) EF SaveChanges() 报错(转载) C# 四舍五入 保留两位小数(转载) DataGridView样式生成器使用说明 MSSQL如何将查询结果拼接成字符串 快递查询 C# 通过smtp直接发送邮件 C# 带参访问接口,WebClient方式 C# 发送手机短信 文件 日志 写入 与读取
- 解惑:NFC手机如何轻松读取银行卡信息?
- 解惑:NFC手机如何轻松读取银行卡信息?
- 解惑:NFC手机如何轻松读取银行卡信息?
- android点滴之NFC手机如何轻松读取银行卡信息?
- 解惑:NFC手机如何轻松读取银行卡信息?
- SOAPUI 接口自动化学习笔记节选 如何用Groovy 脚本读取CSV 文件
- .Net语言 APP开发平台——Smobiler学习日志:如何在手机中调用邮件发送接口
- .Net语言 APP开发平台——Smobiler学习日志:如何在手机上实现表单设计
- .Net语言 APP开发平台——Smobiler学习日志:如何在手机上实现折线图表
- android如何修改dex文件添加非法指令 9efa (学习笔记)
- NFC读取卡号学习
- 【学习笔记1】如何在手机调试HelloWorld
- Android系统移植与调试之------->如何修改Android手机NFC模块,使黑屏时候能够使用NFC
- qt中关于如何读取配置文件学习 (vs2008+qt+mysql项目)
- 一步一步跟我学习lucene(15)---java读取word excel pdf及lucene搜索之正则表达式查询RegExQuery和手机邮箱查询示例
- Linux学习笔记——如何使用echo指令向文件写入内容
- Android程序如何读取手机联系人
- .Net语言 APP开发平台——Smobiler学习日志:如何快速在手机上实现ContextMenu