File tree 1 file changed +39
-0
lines changed
1 file changed +39
-0
lines changed Original file line number Diff line number Diff line change
1
+ # Base36
2
+
3
+ The multibase base36 prefix is the character ` k ` or ` K ` . The digit-alphabet
4
+ consists of 0..9 and then the case insensitive range a..z for the values 10..35
5
+
6
+ ## Encoding
7
+
8
+ A byte array is encoded to base36 by:
9
+
10
+ 1 . Counting the number of leading 0 bytes (Z).
11
+ 2 . Interpreting the rest of the byte array as a big-endian unsigned integer (N).
12
+ 3 . Concatenating a length Z string of '0' characters with the decimal
13
+ representation of N.
14
+
15
+ A byte array is encoded to multibase base36 by prefixing its base36 encoding
16
+ with the character ` k ` .
17
+
18
+ ## Decoding
19
+
20
+ A multibase base36 encoded string is decoded by first dropping the multibase
21
+ prefix (which must be ` k ` or ` K ` ).
22
+
23
+ The remaining characters are then converted to a byte array by:
24
+
25
+ 1 . Counting the number of leading '0' characters (Z).
26
+ 2 . Interpreting the rest of the character sequence as a base36 unsigned integer
27
+ (N).
28
+ 3 . Concatenating a length Z array of NULL (0x00) bytes with N encoded as a
29
+ big-endian unsigned integer.
30
+
31
+ ## Examples
32
+
33
+ Byte Array <-> Base36 Multibase:
34
+
35
+ | ---| ---| ---| ---|
36
+ | ` [0x00, 0x01] ` | <-> | ` "k01" ` | ` "K01" ` |
37
+ | ` [0x00, 0x00, 0xff] ` | <-> | ` "k0073" ` | ` "K0073" ` |
38
+ | ` [0x01, 0x00] ` | <-> | ` "k74" ` | ` "K74" ` |
39
+ | ` [0x00, 0x01, 0x00] ` | <-> | ` "k074" ` | ` "K074" ` |
You can’t perform that action at this time.
0 commit comments