'How to make a NFC Tag read only?

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.

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

I get the error:

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


Solution 1:[1]

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

Just call the protect method on the tag object with or without password (without password uses the lock bytes and is permanent read-only).

So the library has got programmed in it the right memory addresses and bits to flip for various cards including all the NTAG21x cards.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1