Back to zzTakeoff Community Channel LogoQ & A
Kyle Bonde - Vertical GC
1h 41m

GUID (Global Unique IDentifier)

Hello,


Does zzTakeoff store a GUID for each takeoff instance?


Trying to figure out the best work-flow to send over to Ediphi and know this will be key for doing bi-directional in the future, nothing urgent as this is a future problem.


0
Stephen Daves zzTakeoff1h 37m

Hi, we do not use a GUID, and instead use a 17-character alphanumeric strings (e.g., J8uR2KxPqL9nZ5t7m)


It would be easy for you to map this format on your side between the two formats using the code below on your system (bonus, its also UUIDv4):


const ALPHABET = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
// 1. Meteor ID -> Valid UUIDv4
function meteorIdToUuid(id) {
  // Convert Base62 Meteor ID to a BigInt (approx 101 bits of entropy)
  let num = 0n;
  for (const char of id) {
    num = num * 62n + BigInt(ALPHABET.indexOf(char));
  }
  // Convert BigInt to 32 hex characters (padded)
  let hex = num.toString(16).padStart(30, '0');
  // Insert UUIDv4 version '4' and variant '8' (bit-compliant)
  // UUIDv4: 8 chars - 4 chars - (4) + 3 chars - (8) + 3 chars - 12 chars
  const part1 = hex.slice(0, 8);   // 8
  const part2 = hex.slice(8, 12);  // 4
  const part3 = hex.slice(12, 15); // 3 (will follow the '4')
  const part4 = hex.slice(15, 18); // 3 (will follow the '8')
  const part5 = hex.slice(18, 30); // 12
  return `${part1}-${part2}-4${part3}-8${part4}-${part5}`;
}
// 2. Valid UUIDv4 -> Meteor ID
function guidToMeteorId(guid) {
  const clean = guid.replace(/-/g, '');
  // Extract only the original data bits (skip the fixed '4' at index 12 and '8' at index 16)
  const hex = clean.slice(0, 12) + clean.slice(13, 16) + clean.slice(17);
  // Convert hex back to BigInt
  let num = BigInt('0x' + hex);
  // Convert BigInt back to Base62 string
  let id = "";
  while (num > 0n) {
    id = ALPHABET[Number(num % 62n)] + id;
    num = num / 62n;
  }
  return id.padStart(17, ALPHABET[0]); // Ensure 17 chars
}
// --- Test ---
const originalId = "J8uR2KxPqL9nZ5t7m";
const validUuid = meteorIdToUuid(originalId);
const restoredId = guidToMeteorId(validUuid);
console.log("Original Meteor ID:", originalId);
console.log("Strict Valid UUIDv4:", validUuid); // Matches xxxxxxxx-xxxx-4xxx-8xxx-xxxxxxxxxxxx
console.log("Restored Meteor ID: ", restoredId); // J8uR2KxPqL9nZ5t7m
You must be logged in to post replies. If you don't have an account you can signup here.