Base32
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.
1 API
| (require base32) | package: base32 | 
1.1 Encoding and decoding byte-strings
procedure
(base32-decode-bytes b32) → bytes?
b32 : base32? 
procedure
(base32-encode-bytes bs) → base32?
bs : bytes? 
1.2 Encoding and decoding ports
procedure
(base32-decode in [#:close? close?]) → input-port?
in : input-port? close? : boolean? = #t 
If close? is #t, in will be closed once eof is reached.
procedure
(base32-encode in [#:close? close?]) → input-port?
in : input-port? close? : boolean? = #t 
If close? is #t, in will be closed once eof is reached.
1.3 Comparing base32 strings
Because some characters are synonymous, two Base32 encodings may be representationally equivalent but not structurally equivalent.
> (define-values (x y) (values "ABC0123" "abcoi23")) > (equal? x y) #f
> (base32=? x y) #t
> (string<? x y) #t
> (base32<? x y) #f
2 Conversion table
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  |