@dracoe/tail-number-gen
v1.0.3
Published
UID to visual tail number (F11 flight-controller convention)
Downloads
265
Readme
@dracoe/tail-number-gen
Converts a hex UID to a 6-character visual tail number. Identical output to the C, Go, and Python implementations in the same family.
Install
npm install @patrick_dracoe/tail-number-genUsage
const { uidToTail } = require('@patrick_dracoe/tail-number-gen');
uidToTail('1A2B3C4D5E6F7081'); // '3Z4P18'
uidToTail('1A2B3C4D-5E6F7081-9A2B3C4D'); // spaces and hyphens stripped
uidToTail('a1b2c3d4'); // case-insensitiveTypeScript types are included.
API
uidToTail(uid: string): string
Accepts 1–36 hex characters. Spaces and hyphens are ignored. Short UIDs are left-padded with zeros.
Throws Error if the UID is empty or contains non-hex characters.
Algorithm
- Strip spaces/hyphens, uppercase, left-pad to 36 hex digits
- SHA-256 the normalized ASCII string
- Take the first 4 bytes as a big-endian uint32
- Reduce mod 34⁶, base-34 encode to 6 characters (alphabet excludes I and O)
No dependencies — uses Node's built-in crypto module.
