Constructor
new MifareClassic(rfReader)
Mifare Classic操作接口
Name | Type | Description |
---|---|---|
rfReader | RfReader | 读卡器设备对象 |
- Source
Members
BLOCK_SIZE
块字节大小
- Source
KEY_DEFAULT
出厂默认密钥
- Source
KEY_SIZE
密匙字节大小
- Source
MAX_BLOCK_COUNT
最大块数量
- Source
MAX_SECTOR_COUNT
最大扇区数量
- Source
POWER_DEFAULT
标准默认控制码
- Source
POWER_DEFAULT_PRO
推荐默认权限控制码可后悔版,012块AB密匙可读可写 控制块AB密匙不可读 A认证不可写入 B认证可改密匙 B认证可改权限位
- Source
POWER_SIZE
权限位字节大小
- Source
POWER_WLOCK_PRO
特殊权限控制码,写入数据后锁定不可更改 AB密匙认证可读取数据 B认证可修改控制块
- Source
S50_SECTOR_BLOCK_COUNT
常见S50扇区块数量
- Source
S50_SECTOR_COUNT
常见S50扇区数量
- Source
S70_SECTOR_BLOCK_COUNT
S70最大扇区块数量
- Source
SIZE_1K
16个扇区每扇区4块容量(常见S50)
- Source
SIZE_2K
32个扇区每扇区4块容量
- Source
SIZE_4K
40个扇区,前32每扇区4块,后8每扇区16块容量(少见S70)
- Source
SIZE_MINI
5个扇区每扇区4块容量
- Source
Methods
(async) cardNo() → {Promise}
获取前4字节兼容卡号
- Source
err/msg + retval
- Type:
- Promise
(async) deselect() → {Promise}
取消选择
- Source
err/msg
- Type:
- Promise
(async) dumpPowerStr(bitStr) → {Promise}
获取权限位描述字符串的权限码数据
Name | Type | Description |
---|---|---|
bitStr | string | 权限位描述字符串 例如"000|000|000|001" |
- Source
err/msg + retval/power
- Type:
- Promise
(async) getSak() → {Promise}
获取当前的SAK码
- Source
err/msg + retval
- Type:
- Promise
(async) getUid() → {Promise}
获取当前的UID数据
- Source
err/msg + retval
- Type:
- Promise
(async) isSelect() → {Promise}
是否已选择
- Source
err/msg + retval
- Type:
- Promise
(async) parsePowerStr(power) → {Promise}
解析权限码数据为权限位描述字符串
Name | Type | Description |
---|---|---|
power | string | 权限码数据 例如"FF078069" |
- Source
err/msg + retval/bitStr
- Type:
- Promise
(async) protect(isWrite, isCheck) → {Promise}
更改控制块保护 默认为不允许写入控制块
Name | Type | Default | Description |
---|---|---|---|
isWrite | boolean | false | 是否允许写控制块数据 |
isCheck | boolean | true | 是否检查写入权限位正确性 强烈建议开启防止写坏扇区 |
- Source
err/msg
- Type:
- Promise
(async) read(reSelect, sector, pwd, pos, num, keyB, fill) → {Promise}
读取扇区数据
Name | Type | Default | Description |
---|---|---|---|
reSelect | boolean | 是否需要失败后支持继续读写业务操作 | |
sector | number | 扇区索引 | |
pwd | string | 扇区认证密匙 | |
pos | number | 0 | 要读取扇区的起始块 |
num | number | 0 | 读取块数量 默认0自动计算最大可读数量 |
keyB | boolean | false | false=A密匙认证 true=B密匙认证 |
fill | boolean | true | 是否以当前认证密匙智能填充控制块密匙数据 |
- Source
err/msg + retval(成功读取数据大小或负数错误码)/data
- Type:
- Promise
(async) select(uid) → {Promise}
选择UID 只有选择成功后才能进行操作
Name | Type | Description |
---|---|---|
uid | string | 十六进制UID数据 |
- Source
err/msg + retval
- Type:
- Promise
(async) write(reSelect, sector, pwd, data, pos, num, keyB) → {Promise}
写入扇区数据
Name | Type | Default | Description |
---|---|---|---|
reSelect | boolean | 是否需要失败后支持继续读写业务操作 | |
sector | number | 扇区索引 | |
pwd | string | 扇区认证密匙 | |
data | string | 写入数据 注意十六进制数据格式与长度必须正确 | |
pos | number | 0 | 要写入扇区的起始块 |
num | number | 0 | 写入块数量 默认0自动计算最大可写数量 |
keyB | boolean | false | false=A密匙认证 true=B密匙认证 |
- Source
err/msg + retval(成功写入数据大小或负数错误码)
- Type:
- Promise
(async) writeCtl(sector, keyA, keyB, ctl) → {Promise}
写入控制块数据-便利版
Name | Type | Description |
---|---|---|
sector | number | 扇区索引 |
keyA | string | 扇区认证原A密匙 |
keyB | string | 扇区认证原B密匙 |
ctl | string | 写入的新控制块数据 注意十六进制数据格式与长度必须正确 |
- Source
err/msg + retval(错误<1与write含义一致,成功返回1=原密钥方式写完成/2=新密钥方式重写完成)
- Type:
- Promise
(static) errStr(err) → {string}
获取读/写错误码字符串含义
Name | Type | Description |
---|---|---|
err | number | 读/写方法retval错误码 |
- Source
- Type:
- string
(static) getSize(sak) → {number}
依据SAK获取容量大小
Name | Type | Description |
---|---|---|
sak | number | 选择应答的SAK码 |
- Source
参考常量Rokato.MifareClassic.SIZE_
- Type:
- number
(static) isEmulated(sak)
依据SAK判断是否为ISO14443-4协议芯片模拟Mifare Classic
Name | Type | Description |
---|---|---|
sak | number | 选择应答的SAK码 |
- Source