Data encoding
View this section in the spec ↗Covers the 102 data bits (2 TNID variant + 100 payload), written as the 17 characters after the . in a TNID string: 17 characters × 6 bits.
Why 17 characters
The name has its own encoding and the 6 UUID version and variant bits are constants, leaving 102 bits. 102 = 17 × 6: no padding.
Alphabet
64 values, in ASCII order, so encoded strings sort like their bits:
-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyzValue = position in this string, from 0. Full table under Mapping.
Not base64
Same 64 characters as base64url (RFC 4648), different order, so different output for the same bits. Don't use a base64 library.
String layout
One symbol per bit, one group per hex digit. 1–9, A–H are the 17 encoded characters in order; 6-bit characters straddle 4-bit nibbles:
nnnn.nnnn.nnnn.nnnn.nnnn.1111.1122.2222-
3333.3344.4444.5555-
vvvv.5566.6666.7777-
uutt.8888.8899.9999-
AAAA.AABB.BBBB.CCCC.CCDD.DDDD.EEEE.EEFF.FFFF.GGGG.GGHH.HHHH| Symbol | Bits | Role |
|---|---|---|
n | 20 | Name, not part of the data |
v | 4 | UUID version, skipped |
u | 2 | UUID variant, skipped |
t | 2 | TNID variant: last 2 bits of character 7 |
1–9, A–H | 6 each | The 17 encoded characters |
| Characters | Bits |
|---|---|
| 1–6 | First 40 payload bits |
| 7 | 4 payload bits, then 2 TNID variant bits |
| 8–17 | Last 60 payload bits |
Worked example
Data part of user.Br2flcNDfF6LYICnT = d6157337-0ebc-8686-83ab-4075a34cdcde. Character 7, N = 011000, ends in 00: variant 0.
| # | Char | Bits | Value |
|---|---|---|---|
| 1 | B | 001100 | 12 |
| 2 | r | 110111 | 55 |
| 3 | 2 | 000011 | 3 |
| 4 | f | 101011 | 43 |
| 5 | l | 110001 | 49 |
| 6 | c | 101000 | 40 |
| 7 | N | 011000 | 24 |
| 8 | D | 001110 | 14 |
| 9 | f | 101011 | 43 |
| 10 | F | 010000 | 16 |
| 11 | 6 | 000111 | 7 |
| 12 | L | 010110 | 22 |
| 13 | Y | 100011 | 35 |
| 14 | I | 010011 | 19 |
| 15 | C | 001101 | 13 |
| 16 | n | 110011 | 51 |
| 17 | T | 011110 | 30 |
Mapping
Read each column top to bottom.
000000 - 010000 F 100000 V 110000 k
000001 0 010001 G 100001 W 110001 l
000010 1 010010 H 100010 X 110010 m
000011 2 010011 I 100011 Y 110011 n
000100 3 010100 J 100100 Z 110100 o
000101 4 010101 K 100101 _ 110101 p
000110 5 010110 L 100110 a 110110 q
000111 6 010111 M 100111 b 110111 r
001000 7 011000 N 101000 c 111000 s
001001 8 011001 O 101001 d 111001 t
001010 9 011010 P 101010 e 111010 u
001011 A 011011 Q 101011 f 111011 v
001100 B 011100 R 101100 g 111100 w
001101 C 011101 S 101101 h 111101 x
001110 D 011110 T 101110 i 111110 y
001111 E 011111 U 101111 j 111111 z