CPU卡读写操作函数
2015-03-30 14:59
357 查看
CPU卡与传统的MifareOne系列卡相比,具有更加安全、复杂的认证机制,这就意味着CPU卡的读写操作在软件开发中变得更加的复杂。我们这些复杂的操作封装成5个通用的函数,与我们的CPU读写器相结合,让您十分钟就搞定CPU的读写操作。
//'CPU卡寻卡及将卡复位到14443A-4的指令状态
[DllImport("OUR_MIFARE.dll", EntryPoint = "cpurequest")]
static extern byte cpurequest(byte[] serial, byte[] param, byte[] cosver, byte[] code);
//-----------------------------------------------------------------------------------------------------------------------------
//初始化函数,(ctrlword是否需要先清空卡,不需要清空的话,可以需输入卡密码,卡密码长度)ctrlword_0是否先清空卡,分配空间(字节数),
//Public Declare Function cpursinit Lib "OUR_MIFARE.dll" (ByVal ctrlword As Byte, ByVal key As Long, ByVal keylen As Byte, ByVal customsize As Long) As Byte
[DllImport("OUR_MIFARE.dll", EntryPoint = "cpursinit", CallingConvention = CallingConvention.StdCall)]
static extern byte cpursinit(byte ctrlword, byte[] key, byte[] keylen, Int32 customsize);
//-----------------------------------------------------------------------------------------------------------------------------
//增加文件(文件序号0~5,文件只读密码:长度,文件读写密码,长度,分配空间)
//Public Declare Function cpursfileadd Lib "OUR_MIFARE.dll" (ByVal fileno As Byte, ByVal readonlykey As Long, ByVal readonlykeylen As Byte, ByVal writekey As Long, ByVal writekeylen As Byte, ByVal customsize As Long) As Byte
[DllImport("OUR_MIFARE.dll", EntryPoint = "cpursfileadd", CallingConvention = CallingConvention.StdCall)]
static extern byte cpursfileadd(byte fileno, byte[] readonlykey, byte[] readonlykeylen, byte[] writekey, byte[] writekeylen, Int32 customsize);
//-----------------------------------------------------------------------------------------------------------------------------
//'修改文件密码,修改后,请妥慎记住,否则该文件将无法再用
//Public Declare Function cpursfilekeychg Lib "OUR_MIFARE.dll" (ByVal fileno As Byte, ByVal keytype As Byte, ByVal oldkey As Long, ByVal oldkeylen As Byte, ByVal newkey As Long, ByVal newkeylen As Byte) As Byte
[DllImport("OUR_MIFARE.dll", EntryPoint = "cpursfilekeychg", CallingConvention = CallingConvention.StdCall)]
static extern byte cpursfilekeychg(byte fileno, byte keytype, byte[] oldkey, byte[] oldkeylen, byte[] newkey, byte[] newkeylen);
//-----------------------------------------------------------------------------------------------------------------------------
//'修改卡密码,卡密码和文件没有任何关系,卡密码只是用来清空卡,读和写文件是无效的。
//Public Declare Function cpurscardkeychg Lib "OUR_MIFARE.dll" (ByVal oldkey As Long, ByVal oldkeylen As Byte, ByVal newkey As Long, ByVal newkeylen As Byte) As Byte
[DllImport("OUR_MIFARE.dll", EntryPoint = "cpurscardkeychg", CallingConvention = CallingConvention.StdCall)]
static extern byte cpurscardkeychg(byte fileno, byte[] readonlykey, byte[] readonlykeylen, byte[] writekey, byte[] writekeylen, Int32 customsize);
//-----------------------------------------------------------------------------------------------------------------------------
//读文件数据(文件序号,读写密码,密码长度,读取起始位置,读取长度,读出内容)
//Public Declare Function cpursfiledataread Lib "OUR_MIFARE.dll" (ByVal fileno As Byte, ByVal keytype As Byte, ByVal key As Long, ByVal keylen As Byte, ByVal startaddr As Long, ByVal databuf As Long, ByVal datalen As Long) As Byte
[DllImport("OUR_MIFARE.dll", EntryPoint = "cpursfiledataread", CallingConvention = CallingConvention.StdCall)]
static extern byte cpursfiledataread(byte fileno, byte keytype, byte[] rwkey, byte[] rwkeylen, Int32 startaddr, byte[] databuf, Int32 datalen);
//-----------------------------------------------------------------------------------------------------------------------------
//写文件数据(文件序号,文件读写密码,密码长度,写入起始位置,写入长度,写入内容)
//Public Declare Function cpursfiledatawrite Lib "OUR_MIFARE.dll" (ByVal fileno As Byte, ByVal keytype As Byte, ByVal key As Long, ByVal keylen As Byte, ByVal startaddr As Long, ByVal databuf As Long, ByVal datalen As Long) As Byte
[DllImport("OUR_MIFARE.dll", EntryPoint = "cpursfiledatawrite", CallingConvention = CallingConvention.StdCall)]
static extern byte cpursfiledatawrite(byte fileno, byte keytype, byte[] rwkey, byte[] rwkeylen, Int32 startaddr, byte[] databuf, Int32 datalen);
//-----------------------------------------------------------------------------------------------------------------------------
//修改卡密码,卡密码和文件没有任何关系,卡密码只是用来清空卡,读和写文件是无效的。
//Public Declare Function cpurscardkeychg Lib "OUR_MIFARE.dll" (ByVal oldkey As Long, ByVal oldkeylen As Byte, ByVal newkey As Long, ByVal newkeylen As Byte) As Byte
[DllImport("OUR_MIFARE.dll", EntryPoint = "cpurscardkeychg", CallingConvention = CallingConvention.StdCall)]
static extern byte cpurscardkeychg(byte[] oldkey, byte[] oldlen, byte[] newkey, byte[] newlen);
//'CPU卡寻卡及将卡复位到14443A-4的指令状态
[DllImport("OUR_MIFARE.dll", EntryPoint = "cpurequest")]
static extern byte cpurequest(byte[] serial, byte[] param, byte[] cosver, byte[] code);
//-----------------------------------------------------------------------------------------------------------------------------
//初始化函数,(ctrlword是否需要先清空卡,不需要清空的话,可以需输入卡密码,卡密码长度)ctrlword_0是否先清空卡,分配空间(字节数),
//Public Declare Function cpursinit Lib "OUR_MIFARE.dll" (ByVal ctrlword As Byte, ByVal key As Long, ByVal keylen As Byte, ByVal customsize As Long) As Byte
[DllImport("OUR_MIFARE.dll", EntryPoint = "cpursinit", CallingConvention = CallingConvention.StdCall)]
static extern byte cpursinit(byte ctrlword, byte[] key, byte[] keylen, Int32 customsize);
//-----------------------------------------------------------------------------------------------------------------------------
//增加文件(文件序号0~5,文件只读密码:长度,文件读写密码,长度,分配空间)
//Public Declare Function cpursfileadd Lib "OUR_MIFARE.dll" (ByVal fileno As Byte, ByVal readonlykey As Long, ByVal readonlykeylen As Byte, ByVal writekey As Long, ByVal writekeylen As Byte, ByVal customsize As Long) As Byte
[DllImport("OUR_MIFARE.dll", EntryPoint = "cpursfileadd", CallingConvention = CallingConvention.StdCall)]
static extern byte cpursfileadd(byte fileno, byte[] readonlykey, byte[] readonlykeylen, byte[] writekey, byte[] writekeylen, Int32 customsize);
//-----------------------------------------------------------------------------------------------------------------------------
//'修改文件密码,修改后,请妥慎记住,否则该文件将无法再用
//Public Declare Function cpursfilekeychg Lib "OUR_MIFARE.dll" (ByVal fileno As Byte, ByVal keytype As Byte, ByVal oldkey As Long, ByVal oldkeylen As Byte, ByVal newkey As Long, ByVal newkeylen As Byte) As Byte
[DllImport("OUR_MIFARE.dll", EntryPoint = "cpursfilekeychg", CallingConvention = CallingConvention.StdCall)]
static extern byte cpursfilekeychg(byte fileno, byte keytype, byte[] oldkey, byte[] oldkeylen, byte[] newkey, byte[] newkeylen);
//-----------------------------------------------------------------------------------------------------------------------------
//'修改卡密码,卡密码和文件没有任何关系,卡密码只是用来清空卡,读和写文件是无效的。
//Public Declare Function cpurscardkeychg Lib "OUR_MIFARE.dll" (ByVal oldkey As Long, ByVal oldkeylen As Byte, ByVal newkey As Long, ByVal newkeylen As Byte) As Byte
[DllImport("OUR_MIFARE.dll", EntryPoint = "cpurscardkeychg", CallingConvention = CallingConvention.StdCall)]
static extern byte cpurscardkeychg(byte fileno, byte[] readonlykey, byte[] readonlykeylen, byte[] writekey, byte[] writekeylen, Int32 customsize);
//-----------------------------------------------------------------------------------------------------------------------------
//读文件数据(文件序号,读写密码,密码长度,读取起始位置,读取长度,读出内容)
//Public Declare Function cpursfiledataread Lib "OUR_MIFARE.dll" (ByVal fileno As Byte, ByVal keytype As Byte, ByVal key As Long, ByVal keylen As Byte, ByVal startaddr As Long, ByVal databuf As Long, ByVal datalen As Long) As Byte
[DllImport("OUR_MIFARE.dll", EntryPoint = "cpursfiledataread", CallingConvention = CallingConvention.StdCall)]
static extern byte cpursfiledataread(byte fileno, byte keytype, byte[] rwkey, byte[] rwkeylen, Int32 startaddr, byte[] databuf, Int32 datalen);
//-----------------------------------------------------------------------------------------------------------------------------
//写文件数据(文件序号,文件读写密码,密码长度,写入起始位置,写入长度,写入内容)
//Public Declare Function cpursfiledatawrite Lib "OUR_MIFARE.dll" (ByVal fileno As Byte, ByVal keytype As Byte, ByVal key As Long, ByVal keylen As Byte, ByVal startaddr As Long, ByVal databuf As Long, ByVal datalen As Long) As Byte
[DllImport("OUR_MIFARE.dll", EntryPoint = "cpursfiledatawrite", CallingConvention = CallingConvention.StdCall)]
static extern byte cpursfiledatawrite(byte fileno, byte keytype, byte[] rwkey, byte[] rwkeylen, Int32 startaddr, byte[] databuf, Int32 datalen);
//-----------------------------------------------------------------------------------------------------------------------------
//修改卡密码,卡密码和文件没有任何关系,卡密码只是用来清空卡,读和写文件是无效的。
//Public Declare Function cpurscardkeychg Lib "OUR_MIFARE.dll" (ByVal oldkey As Long, ByVal oldkeylen As Byte, ByVal newkey As Long, ByVal newkeylen As Byte) As Byte
[DllImport("OUR_MIFARE.dll", EntryPoint = "cpurscardkeychg", CallingConvention = CallingConvention.StdCall)]
static extern byte cpurscardkeychg(byte[] oldkey, byte[] oldlen, byte[] newkey, byte[] newlen);
相关文章推荐
- 几个针对Cookie 读写操作的Javascript 函数
- Linux下文件读写操作一例(C标准库函数方式实现)
- C#中的读写文件操作函数总结
- 7.打开文件、文件读写操作、with方式、文件常用函数
- PHP文件读写操作相关函数学习资料笔记
- 一个非常非常非常基础的程序,写的不好,但是一般的文件读写操作及字符处理函数都涉及到了..新手学习用的
- C语言文件读写操作中缓冲区问题和setbuf函数详解
- C语言文件读写操作中缓冲区问题和setbuf函数详解
- PHP文件读写操作相关函数学习资料笔记
- 【工作总结】一组关于key=value类似配置文件的读写操作函数
- C语言文件读写操作主要函数及其用例
- c#读写共享内存操作函数封装
- 函数 及文件读写操作,装饰器
- pig数据结构、读写操作、诊断操作、内建函数
- C语言文件读写操作中缓冲区问题和setbuf函数详解
- fread()和fwrite()函数读写文件操作
- PHP文件读写操作相关函数总结
- linux文件操作函数(open、write、read、close)可用于串口读写
- 文件的操作2-----读写文件/移动文件读写指针位置/重回文件头部、fprintf()函数、freopen函数
- python open函数关于w+ r+ 读写操作的理解