NFC: The Secret Power of a Tap

Offline learning lab. No real device scans or network requests.

1. Model two coils

An illustrative score falls with distance and poor alignment. It is not a measured NFC range or a physical coupling law.

function coupling(d, alignment) {
  if (d < 0 || alignment < 0 || alignment > 1)
    throw Error("Invalid model input");
  return alignment / (1 + d * d);
}

Example: coupling(2,1)

Compare the two scores and explain what this model ignores.

2. Count the message bytes

Measure the UTF-8 payload. NDEF headers add overhead, so this is not a full NDEF encoder.

function fitsText(text, budget) {
  const bytes = new TextEncoder().encode(text).length;
  return {bytes, fits: bytes <= budget};
}

Example: fitsText("Hello",8)

Try a longer text or emoji and compare the byte count.

3. Design a cautious tap interface

The toy interface allows HTTPS links to a predefined educational host. It never opens a link. An expected host alone does not prove safety.

function classifyTap(value) {
  try {
    const u = new URL(value);
    return u.protocol === "https:" &&
      u.hostname === "museum.example" &&
      !u.username && !u.password && !u.port
      ? "Review known host" : "Do not open";
  } catch { return "Not a web address"; }
}

Example: classifyTap("https://museum.example/exhibit")

Why should Bit review even an expected host?

Return to the companion index