16

There is enough information on how to implement base32 encoding or the specification of base32 encoding but I don't understand what it is, why we need it and where are the primary applications. Can someone please explain and give nice real life scenarios on usage? Thanks.

crockford base32 wikipedia base32

Jeff
  • 13,079
  • 23
  • 71
  • 102

3 Answers3

20

Like any other "ASCII-only" encoding, base32's primary purpose is to make sure that the data it encodes will survive transportation through systems or protocols which have special restrictions on the range of characters they will accept and emerge unmodified.

For example, b32-encoded data can be passed to a system that accepts single-byte character input, or UTF-8 encoded string input, or appended to a URL, or added to HTML content, without being mangled or resulting in an invalid form. Base64 (which is much more common) is used for the exact same reasons.

The main advantage of b32 over b64 is that it is much more human-readable. That's not much of an advantage because the data will typically be processed by computers, hence the relative rarity of b32 versus b64 (which is more efficient space-wise).

Update: there's the same question asked about Base64 here: What is base 64 encoding used for?

Community
  • 1
  • 1
Jon
  • 428,835
  • 81
  • 738
  • 806
  • I would add that in theory, base32 can be case insensitive. – snapfractalpop Feb 01 '18 at 05:13
  • I agree with @snapfractalpop. If you doing something where the protocol (like dns) could change case, then base32 is more useful. If you not worrying about that, then base64 will allow the same content to be encoded in less characters then base32. (see valex's answer) – AmaJayJB Mar 13 '18 at 15:03
4

Base32 encoding (and Base64) encoding is motivated by situations where you need to encode unrestricted binary within a storage or transport system that allow only data of a certain form such as plain text. Examples include passing data through URLs, XML, or JSON data, all of which are plain text sort of formats that don't otherwise permit or support arbitrary binary data.

DuckMaestro
  • 15,232
  • 11
  • 67
  • 85
3

In addition to previous answers for base32 vs base64 in numbers. For same .pdf file encoded result is:

base64.base32encode(content) = 190400 symbols

base64.base64encode(content) = 158668 symbols

valex
  • 5,163
  • 2
  • 33
  • 40
  • 3
    Well, sure. Lower base = more digits to represent the same number. In this case, base64 is 5/6 the size of base32, because base32 gets you log2(32)=5 bits per character, while base64 gets you log2(64)=6 bits per character. – Mark Reed Sep 13 '22 at 18:42