python-clinic / Doc / library / binascii.rst

Full commit

:mod:`binascii` --- Convert between binary and ASCII

The :mod:`binascii` module contains a number of methods to convert between binary and various ASCII-encoded binary representations. Normally, you will not use these functions directly but use wrapper modules like :mod:`uu`, :mod:`base64`, or :mod:`binhex` instead. The :mod:`binascii` module contains low-level functions written in C for greater speed that are used by the higher-level modules.


a2b_* functions accept Unicode strings containing only ASCII characters. Other functions only accept :term:`bytes-like object`s (such as :class:`bytes`, :class:`bytearray` and other objects that support the buffer protocol).

The :mod:`binascii` module defines the following functions:


To generate the same numeric value across all Python versions and platforms use crc32(data) & 0xffffffff. If you are only using the checksum in packed binary format this is not necessary as the return value is the correct 32bit binary representation regardless of sign.