SDM Encoding
Programming SDM
encodeTag(profile, params?)
Configure the tag for Secure Dynamic Messaging (auth: Key 0, automatic). This is the main “program a tag” entry point. profile is 'plain', 'encrypted', or 'full'.
| Param | Default | Meaning |
|---|---|---|
resetCounter | false | Reset SDM counter before encoding |
ndefType | 'url' | 'url' or 'text' |
url | — | Required when ndefType='url' (with ndefType='text' the tag builds its own JSON — no text input) |
counterLimit | null | Counter cap (1–16777215) |
fileData | 'SecureData123456' | Static plain (UTF-8) string for the 'full' profile, space-padded to encSize/2 bytes before encryption |
encSize | 32 | Encryption size for 'full': 32, 64, or 128 |
enableTTStatus | false | Mirror TagTamper status (full profile, TagTamper variant) |
compressed | false | Shorter URLs without parameter names |
sdmSettings | null | Advanced SDM access-rights override |
// plain — UID + counter + CMAC mirrored in cleartextawait tag.encodeTag('plain', { url: 'https://example.com/t' });
// encrypted — PICCData (UID + counter) encrypted + CMACawait tag.encodeTag('encrypted', { url: 'https://example.com/t' });
// full — encrypted PICCData + encrypted file data + CMACconst res = await tag.encodeTag('full', { url: 'https://example.com/t', fileData: 'HelloWorld!', encSize: 32,});Returns
{ success: true, data: { profile: 'full', compressed: false, pattern: 'https://example.com/t?picc_data=00000000000000000000000000000000&enc=00000000000000000000000000000000&cmac=0000000000000000', counterLimit: null, sdmSettings: null, piccDataSize: 32, fileData: 'HelloWorld! ', // input space-padded to encSize/2 = 16 bytes (plain UTF-8, not hex) enableTTStatus: false }, duration: 38}Turning SDM Off
disableSDM(fileNo?)
Disable SDM on a file (back to plain mode, default access rights, counter reset). fileNo defaults to 2 (NDEF).
const res = await tag.disableSDM();Returns
{ success: true, data: { enabled: false }, duration: 21}