The Base16, Base32, and Base64 Data Encodings
RFC 4648

Document Type RFC - Proposed Standard (October 2006; Errata)
Obsoletes RFC 3548
Was draft-josefsson-rfc3548bis (individual in gen area)
Last updated 2013-03-02
Stream IETF
Formats plain text pdf html
Stream WG state (None)
Consensus Unknown
Document shepherd No shepherd assigned
IESG IESG state RFC 4648 (Proposed Standard)
Telechat date
Responsible AD Ted Hardie
Send notices to simon@josefsson.org
Network Working Group                                       S. Josefsson
Request for Comments: 4648                                           SJD
Obsoletes: 3548                                             October 2006
Category: Standards Track

             The Base16, Base32, and Base64 Data Encodings

Status of This Memo

   This document specifies an Internet standards track protocol for the
   Internet community, and requests discussion and suggestions for
   improvements.  Please refer to the current edition of the "Internet
   Official Protocol Standards" (STD 1) for the standardization state
   and status of this protocol.  Distribution of this memo is unlimited.

Copyright Notice

   Copyright (C) The Internet Society (2006).

Abstract

   This document describes the commonly used base 64, base 32, and base
   16 encoding schemes.  It also discusses the use of line-feeds in
   encoded data, use of padding in encoded data, use of non-alphabet
   characters in encoded data, use of different encoding alphabets, and
   canonical encodings.

Josefsson                   Standards Track                     [Page 1]
RFC 4648                    Base-N Encodings                October 2006

Table of Contents

   1. Introduction ....................................................3
   2. Conventions Used in This Document ...............................3
   3. Implementation Discrepancies ....................................3
      3.1. Line Feeds in Encoded Data .................................3
      3.2. Padding of Encoded Data ....................................4
      3.3. Interpretation of Non-Alphabet Characters in Encoded Data ..4
      3.4. Choosing the Alphabet ......................................4
      3.5. Canonical Encoding .........................................5
   4. Base 64 Encoding ................................................5
   5. Base 64 Encoding with URL and Filename Safe Alphabet ............7
   6. Base 32 Encoding ................................................8
   7. Base 32 Encoding with Extended Hex Alphabet ....................10
   8. Base 16 Encoding ...............................................10
   9. Illustrations and Examples .....................................11
   10. Test Vectors ..................................................12
   11. ISO C99 Implementation of Base64 ..............................14
   12. Security Considerations .......................................14
   13. Changes Since RFC 3548 ........................................15
   14. Acknowledgements ..............................................15
   15. Copying Conditions ............................................15
   16. References ....................................................16
      16.1. Normative References .....................................16
      16.2. Informative References ...................................16

Josefsson                   Standards Track                     [Page 2]
RFC 4648                    Base-N Encodings                October 2006

1.  Introduction

   Base encoding of data is used in many situations to store or transfer
   data in environments that, perhaps for legacy reasons, are restricted
   to US-ASCII [1] data.  Base encoding can also be used in new
   applications that do not have legacy restrictions, simply because it
   makes it possible to manipulate objects with text editors.

   In the past, different applications have had different requirements
   and thus sometimes implemented base encodings in slightly different
   ways.  Today, protocol specifications sometimes use base encodings in
   general, and "base64" in particular, without a precise description or
   reference.  Multipurpose Internet Mail Extensions (MIME) [4] is often
   used as a reference for base64 without considering the consequences
   for line-wrapping or non-alphabet characters.  The purpose of this
   specification is to establish common alphabet and encoding
   considerations.  This will hopefully reduce ambiguity in other
   documents, leading to better interoperability.

2.  Conventions Used in This Document

   The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT",
   "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this
   document are to be interpreted as described in [2].

3.  Implementation Discrepancies

   Here we discuss the discrepancies between base encoding
   implementations in the past and, where appropriate, mandate a
   specific recommended behavior for the future.

3.1.  Line Feeds in Encoded Data
Show full document text