Skip to main content

Fast Base64 encoding/decoding

Project description

Fast Base64 implementation

license-status pypi-status python-versions Documentation Status travis-status appveyor-status codecov-status

This project is a wrapper on libbase64.

It aims to provide a fast base64 implementation for base64 encoding/decoding.

Installation

pip install pybase64

Usage

pybase64 uses the same API as Python base64 “modern interface” (introduced in Python 2.4) for an easy integration.

To get the fastest decoding, it is recommended to use the pybase64.b64decode and validate=True when possible.

import pybase64

print(pybase64.b64encode(b'>>>foo???', altchars='_:'))
# b'Pj4_Zm9vPz8:'
print(pybase64.b64decode(b'Pj4_Zm9vPz8:', altchars='_:', validate=True))
# b'>>>foo???'

# Standard encoding helpers
print(pybase64.standard_b64encode(b'>>>foo???'))
# b'Pj4+Zm9vPz8/'
print(pybase64.standard_b64decode(b'Pj4+Zm9vPz8/'))
# b'>>>foo???'

# URL safe encoding helpers
print(pybase64.urlsafe_b64encode(b'>>>foo???'))
# b'Pj4-Zm9vPz8_'
print(pybase64.urlsafe_b64decode(b'Pj4-Zm9vPz8_'))
# b'>>>foo???'

A command-line tool is also provided. It has encode, decode and benchmark subcommands.

usage: pybase64 [-h] [-V] {benchmark,encode,decode} ...

pybase64 command-line tool.

positional arguments:
  {benchmark,encode,decode}
                        tool help
    benchmark           -h for usage
    encode              -h for usage
    decode              -h for usage

optional arguments:
  -h, --help            show this help message and exit
  -V, --version         show program's version number and exit

Full documentation on Read the Docs.

Benchmark

Running Python 3.7.2, Apple LLVM version 10.0.0 (clang-1000.11.45.5), Mac OS X 10.14.2 on an Intel Core i7-4870HQ @ 2.50GHz

pybase64 0.5.0 (C extension active - AVX2)
bench: altchars=None, validate=False
pybase64._pybase64.encodebytes:   1734.776 MB/s (13,271,472 bytes -> 17,928,129 bytes)
pybase64._pybase64.b64encode:     4039.539 MB/s (13,271,472 bytes -> 17,695,296 bytes)
pybase64._pybase64.b64decode:     1854.423 MB/s (17,695,296 bytes -> 13,271,472 bytes)
base64.encodebytes:                 78.352 MB/s (13,271,472 bytes -> 17,928,129 bytes)
base64.b64encode:                  539.840 MB/s (13,271,472 bytes -> 17,695,296 bytes)
base64.b64decode:                  287.826 MB/s (17,695,296 bytes -> 13,271,472 bytes)
bench: altchars=None, validate=True
pybase64._pybase64.b64encode:     4156.607 MB/s (13,271,472 bytes -> 17,695,296 bytes)
pybase64._pybase64.b64decode:     4107.997 MB/s (17,695,296 bytes -> 13,271,472 bytes)
base64.b64encode:                  559.342 MB/s (13,271,472 bytes -> 17,695,296 bytes)
base64.b64decode:                  143.674 MB/s (17,695,296 bytes -> 13,271,472 bytes)
bench: altchars=b'-_', validate=False
pybase64._pybase64.b64encode:     2786.776 MB/s (13,271,472 bytes -> 17,695,296 bytes)
pybase64._pybase64.b64decode:     1124.136 MB/s (17,695,296 bytes -> 13,271,472 bytes)
base64.b64encode:                  322.427 MB/s (13,271,472 bytes -> 17,695,296 bytes)
base64.b64decode:                  205.195 MB/s (17,695,296 bytes -> 13,271,472 bytes)
bench: altchars=b'-_', validate=True
pybase64._pybase64.b64encode:     2806.271 MB/s (13,271,472 bytes -> 17,695,296 bytes)
pybase64._pybase64.b64decode:     2740.456 MB/s (17,695,296 bytes -> 13,271,472 bytes)
base64.b64encode:                  314.709 MB/s (13,271,472 bytes -> 17,695,296 bytes)
base64.b64decode:                  121.803 MB/s (17,695,296 bytes -> 13,271,472 bytes)

Changelog

1.1.0

  • Add b64encode_as_string, same as b64encode but returns a str object instead of a bytes object

  • Add b64decode_as_bytearray, same as b64decode but returns a bytarray object instead of a bytes object

  • Speed-Up decoding from UCS1 strings

1.0.2

  • Update base64 library

  • Publish python 3.9 wheels

1.0.1

  • Publish python 3.8 wheels

1.0.0

  • Drop python 3.4 support

  • Drop python 2.7 support

0.5.0

  • Publish python 3.7 wheels

  • Drop python 3.3 support

0.4.0

  • Speed-up decoding when validate==False

0.3.1

  • Fix deployment issues

0.3.0

  • Add encodebytes function

0.2.1

  • Fixed invalid results on Windows

0.2.0

  • Added documentation

  • Added subcommands to the main script:

    • help

    • version

    • encode

    • decode

    • benchmark

0.1.2

  • Updated base64 native library

0.1.1

  • Fixed deployment issues

0.1.0

  • First public release

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

pybase64-1.1.0-cp39-cp39-win_amd64.whl (41.1 kB view details)

Uploaded CPython 3.9Windows x86-64

pybase64-1.1.0-cp39-cp39-win32.whl (37.4 kB view details)

Uploaded CPython 3.9Windows x86

pybase64-1.1.0-cp38-cp38-win_amd64.whl (41.2 kB view details)

Uploaded CPython 3.8Windows x86-64

pybase64-1.1.0-cp38-cp38-win32.whl (37.5 kB view details)

Uploaded CPython 3.8Windows x86

pybase64-1.1.0-cp37-cp37m-win_amd64.whl (41.0 kB view details)

Uploaded CPython 3.7mWindows x86-64

pybase64-1.1.0-cp37-cp37m-win32.whl (37.4 kB view details)

Uploaded CPython 3.7mWindows x86

pybase64-1.1.0-cp36-cp36m-win_amd64.whl (41.0 kB view details)

Uploaded CPython 3.6mWindows x86-64

pybase64-1.1.0-cp36-cp36m-win32.whl (37.4 kB view details)

Uploaded CPython 3.6mWindows x86

pybase64-1.1.0-cp35-cp35m-win_amd64.whl (41.1 kB view details)

Uploaded CPython 3.5mWindows x86-64

pybase64-1.1.0-cp35-cp35m-win32.whl (37.4 kB view details)

Uploaded CPython 3.5mWindows x86

File details

Details for the file pybase64-1.1.0-cp39-cp39-win_amd64.whl.

File metadata

  • Download URL: pybase64-1.1.0-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 41.1 kB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.7.5

File hashes

Hashes for pybase64-1.1.0-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 4e97b0ce20f977f4254a9829a5b137e8e94af6ebc10ecf30ac900300dfe8d270
MD5 7df5531836656a512b28662bf946dfa6
BLAKE2b-256 fda125d2c69973851d3ab48d7b9ea69871aa4af86d3f00d8c863c917c042f9ab

See more details on using hashes here.

File details

Details for the file pybase64-1.1.0-cp39-cp39-win32.whl.

File metadata

  • Download URL: pybase64-1.1.0-cp39-cp39-win32.whl
  • Upload date:
  • Size: 37.4 kB
  • Tags: CPython 3.9, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.7.5

File hashes

Hashes for pybase64-1.1.0-cp39-cp39-win32.whl
Algorithm Hash digest
SHA256 28bde5cc9fe38fb5a75d5c41969485668beca73a5a99c28aa31475e7a69daf1a
MD5 7fb5034f8c2591376c48814d4651894a
BLAKE2b-256 fd41746cf42db15f6f7947b77a3854240fe3add0a606eef58908ce8d79165b88

See more details on using hashes here.

File details

Details for the file pybase64-1.1.0-cp38-cp38-win_amd64.whl.

File metadata

  • Download URL: pybase64-1.1.0-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 41.2 kB
  • Tags: CPython 3.8, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.7.5

File hashes

Hashes for pybase64-1.1.0-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 89fe0a2ac9178e6262ec5284b76a4f89b7f573fabefd043ba69e1c9d22824fe0
MD5 2858d7eae2a717988e6fe4cac409b949
BLAKE2b-256 6de77621648bb42d26620ee07dc2a174b536eb15101d3dd7f66cf62c99c18d36

See more details on using hashes here.

File details

Details for the file pybase64-1.1.0-cp38-cp38-win32.whl.

File metadata

  • Download URL: pybase64-1.1.0-cp38-cp38-win32.whl
  • Upload date:
  • Size: 37.5 kB
  • Tags: CPython 3.8, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.7.5

File hashes

Hashes for pybase64-1.1.0-cp38-cp38-win32.whl
Algorithm Hash digest
SHA256 496087dcb7ee77375a32e8ad3f06c6926a20d8bf47e8457afeca35b89f1895a0
MD5 28f64fc29657e5f28493d9d36cf66914
BLAKE2b-256 3835a67f1c1a44dc1e4a18e87b419bb75b195b7e548c1e41ef1b334ad2a63526

See more details on using hashes here.

File details

Details for the file pybase64-1.1.0-cp37-cp37m-win_amd64.whl.

File metadata

  • Download URL: pybase64-1.1.0-cp37-cp37m-win_amd64.whl
  • Upload date:
  • Size: 41.0 kB
  • Tags: CPython 3.7m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.7.5

File hashes

Hashes for pybase64-1.1.0-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 2228b1e50d2950efa0ea825c29581cd451a4ad4b558ad890a83edd989d5508c6
MD5 f9a5a4264e0c38128d9401b848adfc81
BLAKE2b-256 75ab6ed28c1696a823d26ec0ab6da881b64ed04998f08475d165c3dfb8575291

See more details on using hashes here.

File details

Details for the file pybase64-1.1.0-cp37-cp37m-win32.whl.

File metadata

  • Download URL: pybase64-1.1.0-cp37-cp37m-win32.whl
  • Upload date:
  • Size: 37.4 kB
  • Tags: CPython 3.7m, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.7.5

File hashes

Hashes for pybase64-1.1.0-cp37-cp37m-win32.whl
Algorithm Hash digest
SHA256 b00696cf2293aefcd94bcd8f3f196467f3f7db427c3eda51dedd5bebcb3cf6a8
MD5 b8589353962974b94935736286918bf9
BLAKE2b-256 161e73b393309711f31aafa4192489c5c4594be5a2adfb546866bcea0f866980

See more details on using hashes here.

File details

Details for the file pybase64-1.1.0-cp36-cp36m-win_amd64.whl.

File metadata

  • Download URL: pybase64-1.1.0-cp36-cp36m-win_amd64.whl
  • Upload date:
  • Size: 41.0 kB
  • Tags: CPython 3.6m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.7.5

File hashes

Hashes for pybase64-1.1.0-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 110a20ef0afaf99b75f94a3b00a03674ecacd15f60f0485f1dab2e193a4b5226
MD5 df0546146cade5c2c4b919f57dd46581
BLAKE2b-256 8d7479a6a949fe6ae30c80efee2650b7ea5d3166b5e2466f5a2caf6d6d4cc61e

See more details on using hashes here.

File details

Details for the file pybase64-1.1.0-cp36-cp36m-win32.whl.

File metadata

  • Download URL: pybase64-1.1.0-cp36-cp36m-win32.whl
  • Upload date:
  • Size: 37.4 kB
  • Tags: CPython 3.6m, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.7.5

File hashes

Hashes for pybase64-1.1.0-cp36-cp36m-win32.whl
Algorithm Hash digest
SHA256 42574d90a6f793297d2a210d99d44e36b582949d882092ab22d3f5cf674bc1e8
MD5 c34a7b4fd9e43a652d7cecb6a903ee62
BLAKE2b-256 5d2c03cc9de5f224a5d0081c2c7aa30a0d4c58604fc4c44cb9b42de473248d31

See more details on using hashes here.

File details

Details for the file pybase64-1.1.0-cp35-cp35m-win_amd64.whl.

File metadata

  • Download URL: pybase64-1.1.0-cp35-cp35m-win_amd64.whl
  • Upload date:
  • Size: 41.1 kB
  • Tags: CPython 3.5m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.7.5

File hashes

Hashes for pybase64-1.1.0-cp35-cp35m-win_amd64.whl
Algorithm Hash digest
SHA256 d6c1121a856718b7661a6f7d94252f2a666ba3575aca8e67e56e163315bd164a
MD5 c460ada778ea444b9fc04c30c03b6c31
BLAKE2b-256 635b2d95d44cd75cefb238dba9384ad974523f0af0b769905afd745cb20882e0

See more details on using hashes here.

File details

Details for the file pybase64-1.1.0-cp35-cp35m-win32.whl.

File metadata

  • Download URL: pybase64-1.1.0-cp35-cp35m-win32.whl
  • Upload date:
  • Size: 37.4 kB
  • Tags: CPython 3.5m, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.7.5

File hashes

Hashes for pybase64-1.1.0-cp35-cp35m-win32.whl
Algorithm Hash digest
SHA256 38682d23110aa1ffa9b12080f02c6df6c16ede0910ef7a17879cacd2f0271868
MD5 e1c2fbe874fba47c5569ceb43ffca6a5
BLAKE2b-256 a0594ffd098c6a96fbf65e78070e582a9d173ca2aebf515f363b780509a9b5c0

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page