# base64 - pydoc - phpman

> **TLDR:** Encode or decode file or `stdin` to/from base64, to `stdout`.
>
- Encode a file:
  `base64 {{path/to/file}}`
- Wrap encoded output at a specific width (`0` disables wrapping):
  `base64 {{-w|--wrap}} {{0|76|...}} {{path/to/file}}`
- Decode a file:
  `base64 {{-d|--decode}} {{path/to/file}}`
- Encode from `stdin`:
  `{{command}} | base64`
- Decode from `stdin`:
  `{{command}} | base64 {{-d|--decode}}`

*Source: tldr-pages*

---

Help on module base64:

## NAME
    base64 - Base16, Base32, Base64 (RFC 3548), Base85 and Ascii85 data encodings

## MODULE REFERENCE
    <https://docs.python.org/3.10/library/base64.html>

    The following documentation is automatically generated from the Python
    source files.  It may be incomplete, incorrect or include features that
    are considered implementation detail and may vary between Python
    implementations.  When in doubt, consult the module reference at the
    location listed above.

## FUNCTIONS
### a85decode
        Decode the Ascii85 encoded bytes-like object or ASCII string b.

        foldspaces is a flag that specifies whether the 'y' short sequence should be
        accepted as shorthand for 4 consecutive spaces (ASCII 0x20). This feature is
        not supported by the "standard" Adobe encoding.

        adobe controls whether the input sequence is in Adobe Ascii85 format (i.e.
        is framed with <~ and ~>).

        ignorechars should be a byte string containing characters to ignore from the
        input. This should only contain whitespace characters, and by default
        contains all whitespace characters in ASCII.

        The result is returned as a bytes object.

### a85encode
        Encode bytes-like object b using Ascii85 and return a bytes object.

        foldspaces is an optional flag that uses the special short sequence 'y'
        instead of 4 consecutive spaces (ASCII 0x20) as supported by 'btoa'. This
        feature is not supported by the "standard" Adobe encoding.

        wrapcol controls whether the output should have newline (b'\n') characters
        added to it. If this is non-zero, each output line will be at most this
        many characters long.

        pad controls whether the input is padded to a multiple of 4 before
        encoding. Note that the btoa implementation always pads.

        adobe controls whether the encoded byte sequence is framed with <~ and ~>,
        which is used by the Adobe implementation.

### b16decode
        Decode the Base16 encoded bytes-like object or ASCII string s.

        Optional casefold is a flag specifying whether a lowercase alphabet is
        acceptable as input.  For security purposes, the default is False.

        The result is returned as a bytes object.  A binascii.Error is raised if
        s is incorrectly padded or if there are non-alphabet characters present
        in the input.

### b16encode
        Encode the bytes-like object s using Base16 and return a bytes object.

### b32decode
        Decode the base32 encoded bytes-like object or ASCII string s.

        Optional casefold is a flag specifying whether a lowercase alphabet is
        acceptable as input.  For security purposes, the default is False.

        RFC 3548 allows for optional mapping of the digit 0 (zero) to the
        letter O (oh), and for optional mapping of the digit 1 (one) to
        either the letter I (eye) or letter L (el).  The optional argument
        map01 when not None, specifies which letter the digit 1 should be
        mapped to (when map01 is not None, the digit 0 is always mapped to
        the letter O).  For security purposes the default is None, so that
        0 and 1 are not allowed in the input.

        The result is returned as a bytes object.  A binascii.Error is raised if
        the input is incorrectly padded or if there are non-alphabet
        characters present in the input.

### b32encode
        Encode the bytes-like objects using base32 and return a bytes object.

### b32hexdecode
        Decode the base32hex encoded bytes-like object or ASCII string s.

        Optional casefold is a flag specifying whether a lowercase alphabet is
        acceptable as input.  For security purposes, the default is False.

        The result is returned as a bytes object.  A binascii.Error is raised if
        the input is incorrectly padded or if there are non-alphabet
        characters present in the input.

### b32hexencode
        Encode the bytes-like objects using base32hex and return a bytes object.

### b64decode
        Decode the Base64 encoded bytes-like object or ASCII string s.

        Optional altchars must be a bytes-like object or ASCII string of length 2
        which specifies the alternative alphabet used instead of the '+' and '/'
        characters.

        The result is returned as a bytes object.  A binascii.Error is raised if
        s is incorrectly padded.

        If validate is False (the default), characters that are neither in the
        normal base-64 alphabet nor the alternative alphabet are discarded prior
        to the padding check.  If validate is True, these non-alphabet characters
        in the input result in a binascii.Error.

### b64encode
        Encode the bytes-like object s using Base64 and return a bytes object.

        Optional altchars should be a byte string of length 2 which specifies an
        alternative alphabet for the '+' and '/' characters.  This allows an
        application to e.g. generate url or filesystem safe Base64 strings.

### b85decode
        Decode the base85-encoded bytes-like object or ASCII string b

        The result is returned as a bytes object.

### b85encode
        Encode bytes-like object b in base85 format and return a bytes object.

        If pad is true, the input is padded with b'\0' so its length is a multiple of
        4 bytes before encoding.

### decode
        Decode a file; input and output are binary files.

### decodebytes
        Decode a bytestring of base-64 data into a bytes object.

### encode
        Encode a file; input and output are binary files.

### encodebytes
        Encode a bytestring into a bytes object containing multiple lines
        of base-64 data.

### standard_b64decode
        Decode bytes encoded with the standard Base64 alphabet.

        Argument s is a bytes-like object or ASCII string to decode.  The result
        is returned as a bytes object.  A binascii.Error is raised if the input
        is incorrectly padded.  Characters that are not in the standard alphabet
        are discarded prior to the padding check.

### standard_b64encode
        Encode bytes-like object s using the standard Base64 alphabet.

        The result is returned as a bytes object.

### urlsafe_b64decode
        Decode bytes using the URL- and filesystem-safe Base64 alphabet.

        Argument s is a bytes-like object or ASCII string to decode.  The result
        is returned as a bytes object.  A binascii.Error is raised if the input
        is incorrectly padded.  Characters that are not in the URL-safe base-64
        alphabet, and are not a plus '+' or slash '/', are discarded prior to the
        padding check.

        The alphabet uses '-' instead of '+' and '_' instead of '/'.

### urlsafe_b64encode
        Encode bytes using the URL- and filesystem-safe Base64 alphabet.

        Argument s is a bytes-like object to encode.  The result is returned as a
        bytes object.  The alphabet uses '-' instead of '+' and '_' instead of
        '/'.

## DATA
    __all__ = ['encode', 'decode', 'encodebytes', 'decodebytes', 'b64encod...

## FILE
    /usr/lib/python3.10/base64.py


