问题描述
我有一个 NTAG213
NFC 贴纸.我想知道如何让这个贴纸只读.如果稍后我切换到 NTAG215
,我怎么能让那个标签只读.实际制作不同类型的贴纸所涉及的过程是只读的.当我说只读时,我的意思是 NFC 的记录永远无法修改,但设备仍然可以在没有身份验证的情况下读取记录.
I have an NTAG213
NFC sticker. I was wondering how I can make this sticker read only. If later I switch to a NTAG215
, how could I make that tag read only. What is the process involved in actually making different types of stickers read only. When I say read only, I mean the NFC's records cannot ever be modified but devices can still read the records without authentication.
我阅读了https://answers.launchpad.net/nfcpy/+question/242606 并尝试实施它的解决方案
I had a read of https://answers.launchpad.net/nfcpy/+question/242606 and tried to implement it's solution
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
推荐答案
看起来 Python 库有一个简单的方法可以使用锁定字节或通过密码进行只读.
Looking that the Python library it has a simple method to make readonly using lock bytes or via password.
https://nfcpy.readthedocs.io/en/stable-0.10/modules/tag.html#nfc.tag.tt2_nxp.NTAG21x
只需在有或没有密码的情况下调用 tag
对象上的 protect
方法(没有密码使用锁定字节并且是永久只读的).
Just call the protect
method on the tag
object with or without password (without password uses the lock bytes and is permanent read-only).
因此,库已在其中编程了正确的内存地址和位,以便为各种卡(包括所有 NTAG21x 卡)翻转.
So the library has got programmed in it the right memory addresses and bits to flip for various cards including all the NTAG21x cards.
这篇关于如何使NFC标签只读?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!