0

我有一张NTAG213NFC 贴纸。我想知道如何使这个贴纸只读。如果稍后我切换到 a NTAG215,我怎么能让该标签只读。实际制作不同类型的贴纸只读的过程是什么。当我说只读时,我的意思是 NFC 的记录永远不能被修改,但设备仍然可以在没有身份验证的情况下读取记录。

我阅读了https://answers.launchpad.net/nfcpy/+question/242606并尝试实施它的解决方案

import nfc
from time import sleep
from nfc.clf import RemoteTarget
import ndef

clf = nfc.ContactlessFrontend('usb')

while True:
    target = clf.sense(RemoteTarget('106A'), RemoteTarget('106B'), RemoteTarget('212F'))
    if target is None:
        sleep(1)
        continue

    serial = target.sdd_res.hex()
    tag = nfc.tag.activate(clf, target)

    if not tag.ndef:
        print("No NDEF records found!")
        continue
    
    for record in tag.ndef.records:
        print("Found record: " + str(record))

    record = ndef.UriRecord("https://www.example.com")
    tag.ndef.records = [record]
    # Code is fine until it gets to these tag indexes
    tag[15] = tag[15] | 0x0F
    tag[10] = 0xFF
    tag[11] = 0xFF

我得到错误:

  File "test.py", line 26, in <module>
    tag[15] = tag[15] | 0x0F
TypeError: 'NTAG213' object does not support indexing
4

1 回答 1

0

看看 Python 库,它有一个简单的方法可以使用锁定字节或密码进行只读。

https://nfcpy.readthedocs.io/en/stable-0.10/modules/tag.html#nfc.tag.tt2_nxp.NTAG21x

只需在有或没有密码的情况下调用对象protect上的方法tag(没有密码使用锁定字节并且是永久只读的)。

因此,库已经在其中编程了正确的内存地址和位,以便为包括所有 NTAG21x 卡在内的各种卡翻转。

于 2020-08-30T18:02:35.763 回答