Sunday, May 08, 2011

Base32 Encoding

Base32 Encoding, by Douglas Crockford, also creator of JSON, a well known JavaScript expert

This is a human-friendly ASCII-text based encoding.
Very convenient for making IDs and keys,
since base32 is 3.2 times more efficient than simple base 10 numbers,
and 2x more efficient than base16, used for typical GUIDs.

That is like option to get a vehicle
that makes 32 miles per gallon (mpg) instead of 10 mpg,
or 64 instead of typical 20 mpg, or 150 mpg if you already drive Prius.

And at the same time BASE32 eliminates problems
with similar letters and numbers that are hard to distinguish.

1, I, i, L, l ==> 1
0, O, o ==> 0
V, v, U, u ==> 27

Value = Encode Symbol
0 = 0
1 = 1
2 = 2
3 = 3
4 = 4
5 = 5
6 = 6
7 = 7
8 = 8
9 = 9
10 = A
11 = B
12 = C
13 = D
14 = E
15 = F
16 = G
17 = H
18 = J
19 = K
20 = M
21 = N
22 = P
23 = Q
24 = R
25 = S
26 = T
27 = V
28 = W
29 = X
30 = Y
31 = Z

Decode Symbol = Value
0 = 0
1 = 1
2 = 2
3 = 3
4 = 4
5 = 5
6 = 6
7 = 7
8 = 8
9 = 9
A a = 10
B b = 11
C c = 12
D d = 13
E e = 14
F f = 15
G g = 16
H h = 17
I i = 1 (*)
J j = 18
K k = 19
L l = 1 (*)
M m = 20
N n = 21
P p = 22
Q q = 23
R r = 24
S s = 25
T t = 26
V v = 27
U u = 27 (*)
W w = 28
X x = 29
Y y = 30
Z z = 31