Skip to content

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'.

ParamDefaultMeaning
resetCounterfalseReset SDM counter before encoding
ndefType'url''url' or 'text'
urlRequired when ndefType='url' (with ndefType='text' the tag builds its own JSON — no text input)
counterLimitnullCounter cap (1–16777215)
fileData'SecureData123456'Static plain (UTF-8) string for the 'full' profile, space-padded to encSize/2 bytes before encryption
encSize32Encryption size for 'full': 32, 64, or 128
enableTTStatusfalseMirror TagTamper status (full profile, TagTamper variant)
compressedfalseShorter URLs without parameter names
sdmSettingsnullAdvanced SDM access-rights override
// plain — UID + counter + CMAC mirrored in cleartext
await tag.encodeTag('plain', { url: 'https://example.com/t' });
// encrypted — PICCData (UID + counter) encrypted + CMAC
await tag.encodeTag('encrypted', { url: 'https://example.com/t' });
// full — encrypted PICCData + encrypted file data + CMAC
const 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
}