Access Cards

Livvi locks support access using MIFARE® keycards.

Instead of programming a card on an encoder, you assign access by entering the card's UID into the system. The card UID can be associated to a staff member, booking guest, lease resident or visitor.

Whenever using our API, the UID of the card is expected as a decimal number formatted as a string.

Given a 7-byte UID read using the NXP NFC TagInfo App on a smartphone, for example, this is the algorithm to convert it to a decimal number as expected by Livvi:

bytes = split hexValue into pairs of two digits
reversedHex = reverse(bytes).join("")
decimalValue = convert reversedHex from base 16 to base 10

Therefore, it is expected the byte order is reversed before converting the value from hex to decimal.

Test Vector

044c73720a7c80 is converted to 36165181330639876

TypeScript

This is an example function in TypeScript that makes this conversion:

export function hexToDecimal(hex: string): string {
  let normalized = hex.trim();
  if (normalized === '') {
    throw new Error('Hex input must not be empty');
  }

  if (normalized.startsWith('0x') || normalized.startsWith('0X')) {
    normalized = normalized.slice(2);
  }

  normalized = normalized.replace(/[:\s.-]/g, '');

  if (normalized === '') {
    throw new Error('Hex input must not be empty');
  }

  if (!/^[0-9a-fA-F]+$/.test(normalized)) {
    throw new Error('Hex input must contain only hexadecimal digits');
  }

  if (normalized.length % 2 !== 0) {
    normalized = `0${normalized}`;
  }

  const reversed = normalized.match(/.{2}/g)!.reverse().join('');

  return BigInt(`0x${reversed}`).toString(10);
}