James Alexander Feldman-Crough <alex@fldcr.com>
This library provides utilities for converting byte-strings to and from an encoding based on Crockford’s Base32 encoding.
Compared to similar Base32 encodings like RFC 4648, Crockford’s encoding has a few desirable characteristics which make it especially appealing for user-facing use:
Potentially ambiguous characters, like i, I, l, and L are treated as synonyms.
The digits 0 through F have the same value as their hexadecimal counterparts.
The letter U is invalid, lowering the surface area for obscene encodings.
This library deviates from Crockford’s encoding by encoding strings as lower-case by default. Hyphens are also disallowed as spacing and check characters are unimplemented, although this is a shortcoming of the implementation.
procedure
( base32-decode-bytes b32)→bytes?
b32:base32?
procedure
( base32-encode-bytes bs)→base32?
bs:bytes?
procedure
( base32-decode in[#:close?close?])→input-port?
in:input-port?
If close? is #t, in will be closed once eof is reached.
procedure
( base32-encode in[#:close?close?])→input-port?
in:input-port?
If close? is #t, in will be closed once eof is reached.
Because some characters are synonymous, two Base32 encodings may be representationally equivalent but not structurally equivalent.
#f
#t
#t
#f
The following table shows the decimal value for each valid base32 character. When encoding, this library always chooses the first base32 representation in the table below.
base 10
base 32
0
0 o O =
1
1 i I l L
2
2
3
3
4
4
5
5
6
6
7
7
8
8
9
9
10
a A
11
b B
12
c C
13
d D
14
e E
15
f F
16
g G
17
h H
18
j J
19
k K
20
m M
21
n N
22
p P
23
q Q
24
r R
25
s S
26
t T
27
v V
28
w W
29
x X
30
y Y
31
z Z