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.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 Distribution

pybase64-1.0.0.tar.gz (80.9 kB view details)

Uploaded Source

Built Distributions

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

pybase64-1.0.0-cp37-cp37m-win_amd64.whl (29.0 kB view details)

Uploaded CPython 3.7mWindows x86-64

pybase64-1.0.0-cp37-cp37m-win32.whl (27.1 kB view details)

Uploaded CPython 3.7mWindows x86

pybase64-1.0.0-cp37-cp37m-manylinux1_x86_64.whl (62.5 kB view details)

Uploaded CPython 3.7m

pybase64-1.0.0-cp37-cp37m-manylinux1_i686.whl (58.5 kB view details)

Uploaded CPython 3.7m

pybase64-1.0.0-cp37-cp37m-macosx_10_6_intel.whl (40.1 kB view details)

Uploaded CPython 3.7mmacOS 10.6+ Intel (x86-64, i386)

pybase64-1.0.0-cp36-cp36m-win_amd64.whl (28.9 kB view details)

Uploaded CPython 3.6mWindows x86-64

pybase64-1.0.0-cp36-cp36m-win32.whl (27.1 kB view details)

Uploaded CPython 3.6mWindows x86

pybase64-1.0.0-cp36-cp36m-manylinux1_x86_64.whl (62.6 kB view details)

Uploaded CPython 3.6m

pybase64-1.0.0-cp36-cp36m-manylinux1_i686.whl (58.5 kB view details)

Uploaded CPython 3.6m

pybase64-1.0.0-cp36-cp36m-macosx_10_6_intel.whl (40.1 kB view details)

Uploaded CPython 3.6mmacOS 10.6+ Intel (x86-64, i386)

pybase64-1.0.0-cp35-cp35m-win_amd64.whl (29.0 kB view details)

Uploaded CPython 3.5mWindows x86-64

pybase64-1.0.0-cp35-cp35m-win32.whl (27.1 kB view details)

Uploaded CPython 3.5mWindows x86

pybase64-1.0.0-cp35-cp35m-manylinux1_x86_64.whl (62.6 kB view details)

Uploaded CPython 3.5m

pybase64-1.0.0-cp35-cp35m-manylinux1_i686.whl (58.5 kB view details)

Uploaded CPython 3.5m

pybase64-1.0.0-cp35-cp35m-macosx_10_6_intel.whl (40.1 kB view details)

Uploaded CPython 3.5mmacOS 10.6+ Intel (x86-64, i386)

File details

Details for the file pybase64-1.0.0.tar.gz.

File metadata

  • Download URL: pybase64-1.0.0.tar.gz
  • Upload date:
  • Size: 80.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.1

File hashes

Hashes for pybase64-1.0.0.tar.gz
Algorithm Hash digest
SHA256 71a729b10232b38cba001e621dbaa6dbba2302dc44a93706295f1ff760f40876
MD5 dd36b5630403f2b9e6b9769c4c84376e
BLAKE2b-256 fee493774b24079495dd6606a653eb4d8733e095f257c8884eb0cc1cd2fcacae

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pybase64-1.0.0-cp37-cp37m-win_amd64.whl
  • Upload date:
  • Size: 29.0 kB
  • Tags: CPython 3.7m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/2.7.16

File hashes

Hashes for pybase64-1.0.0-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 64da641b248e2fab7d22a2ba4323908bcccac5ed590f2d546bafb802521d3562
MD5 edbe068a249317ac97f37e587423dcd0
BLAKE2b-256 9d89610d83ade8d4ca10c523a4579ed20b1551f53fc8ce2c02fedbef134298e3

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pybase64-1.0.0-cp37-cp37m-win32.whl
  • Upload date:
  • Size: 27.1 kB
  • Tags: CPython 3.7m, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/2.7.16

File hashes

Hashes for pybase64-1.0.0-cp37-cp37m-win32.whl
Algorithm Hash digest
SHA256 6cd4b52797659bc894b09cf7e9d8f8ea1d505688879c08016b9ef35accd92843
MD5 5276a945cf1921847aa3dfe409f05bec
BLAKE2b-256 8c2cb9b1dd9a7b3d08e236eab57822b105b1faa8b3c945ee65638ba01195ec31

See more details on using hashes here.

File details

Details for the file pybase64-1.0.0-cp37-cp37m-manylinux1_x86_64.whl.

File metadata

  • Download URL: pybase64-1.0.0-cp37-cp37m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 62.5 kB
  • Tags: CPython 3.7m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.1

File hashes

Hashes for pybase64-1.0.0-cp37-cp37m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 58d36c3c84df17a71d42352ed8f658da3d2b4272dfba86a4d98e7c8482027cc3
MD5 dcf5155da7ceca94de053bca5ec99193
BLAKE2b-256 89d8dbbe86dd5b1d2c38300727d031b27c2f4978ac6488b26056702264440112

See more details on using hashes here.

File details

Details for the file pybase64-1.0.0-cp37-cp37m-manylinux1_i686.whl.

File metadata

  • Download URL: pybase64-1.0.0-cp37-cp37m-manylinux1_i686.whl
  • Upload date:
  • Size: 58.5 kB
  • Tags: CPython 3.7m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.1

File hashes

Hashes for pybase64-1.0.0-cp37-cp37m-manylinux1_i686.whl
Algorithm Hash digest
SHA256 0840f0d6f141ae666f963ebb22f3b8efa3662af633be6143c35f1cfa4a7bce3d
MD5 82d668ad203e8c19d050ed830d1c63a9
BLAKE2b-256 e3655cb826dda1cb2fce41b84a30f18ed3e9f34bb8f70450d82f7d667753b538

See more details on using hashes here.

File details

Details for the file pybase64-1.0.0-cp37-cp37m-macosx_10_6_intel.whl.

File metadata

  • Download URL: pybase64-1.0.0-cp37-cp37m-macosx_10_6_intel.whl
  • Upload date:
  • Size: 40.1 kB
  • Tags: CPython 3.7m, macOS 10.6+ Intel (x86-64, i386)
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/2.7.14

File hashes

Hashes for pybase64-1.0.0-cp37-cp37m-macosx_10_6_intel.whl
Algorithm Hash digest
SHA256 55ee2e6e4f0a643c894dfe1dbb882431327f68427687e51d16654eb5c34354e5
MD5 c32e23c13ade0ad6e11be317a2599e03
BLAKE2b-256 6d937deb5ea700da016cdbd1b69453b9dbf2130683ccf6dd09c1f4c5dd0de2ce

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pybase64-1.0.0-cp36-cp36m-win_amd64.whl
  • Upload date:
  • Size: 28.9 kB
  • Tags: CPython 3.6m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/2.7.16

File hashes

Hashes for pybase64-1.0.0-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 a1cae58aba4c8d61525f7940a75f2cdd5f7d29eb64159e0734b4359e2e23ad78
MD5 ba0330f048bb60bdeef1fb3073ea6829
BLAKE2b-256 414c644b1f8a6e50a5a0c24813cddd569dfeb01a415b722bfd0043f7c1cb4f66

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pybase64-1.0.0-cp36-cp36m-win32.whl
  • Upload date:
  • Size: 27.1 kB
  • Tags: CPython 3.6m, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/2.7.16

File hashes

Hashes for pybase64-1.0.0-cp36-cp36m-win32.whl
Algorithm Hash digest
SHA256 009fa9ab24e7a5efe252256a6d5f8cf2e93204183ee81d6b6552bef57c588eaf
MD5 a8124efc6ade9a2806d33932ff65c1d6
BLAKE2b-256 9c5befdb97ef95b243a3e7d6e458b41f8658f034d8463e7582d14816ea0a6558

See more details on using hashes here.

File details

Details for the file pybase64-1.0.0-cp36-cp36m-manylinux1_x86_64.whl.

File metadata

  • Download URL: pybase64-1.0.0-cp36-cp36m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 62.6 kB
  • Tags: CPython 3.6m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.1

File hashes

Hashes for pybase64-1.0.0-cp36-cp36m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 43c797281336d66f8976c18e7ea1d5280e7fc650af2e0f0299c87f2f5495e30a
MD5 eba70a0464187c3793a541a8cde454c6
BLAKE2b-256 0b7f6763f6f5b8402f7ea44bb36e80d24d3e90476e9d9ab9e456f1cd8dbfa086

See more details on using hashes here.

File details

Details for the file pybase64-1.0.0-cp36-cp36m-manylinux1_i686.whl.

File metadata

  • Download URL: pybase64-1.0.0-cp36-cp36m-manylinux1_i686.whl
  • Upload date:
  • Size: 58.5 kB
  • Tags: CPython 3.6m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.1

File hashes

Hashes for pybase64-1.0.0-cp36-cp36m-manylinux1_i686.whl
Algorithm Hash digest
SHA256 2c7ee28b24aaf269ae179ae2e78bc4c8c051ef0446911a3a7367526d0a04bd11
MD5 5306140dd8d45b5c7409942f3d022a30
BLAKE2b-256 a812e8f0123cbb85cf29efb2154463456d869c4df77b82721dae052330d9e6e3

See more details on using hashes here.

File details

Details for the file pybase64-1.0.0-cp36-cp36m-macosx_10_6_intel.whl.

File metadata

  • Download URL: pybase64-1.0.0-cp36-cp36m-macosx_10_6_intel.whl
  • Upload date:
  • Size: 40.1 kB
  • Tags: CPython 3.6m, macOS 10.6+ Intel (x86-64, i386)
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/2.7.14

File hashes

Hashes for pybase64-1.0.0-cp36-cp36m-macosx_10_6_intel.whl
Algorithm Hash digest
SHA256 6bc3c77b67cb64d69d49dfb3caffde90a6529da83ee316b8d262682a1cb18839
MD5 c99923d583440ca54bf3d65255168d31
BLAKE2b-256 f1db0227a18a28d641c8a1606de9e91c3629ecef9fd51a56e8997405cbfeabd2

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pybase64-1.0.0-cp35-cp35m-win_amd64.whl
  • Upload date:
  • Size: 29.0 kB
  • Tags: CPython 3.5m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/2.7.16

File hashes

Hashes for pybase64-1.0.0-cp35-cp35m-win_amd64.whl
Algorithm Hash digest
SHA256 9adaa10b045c6e91b9beb89ba21208901bf562c7a9fcd56d796d5ce18d782b36
MD5 c2c5dca0f27deb19d40c2e6d0c221abb
BLAKE2b-256 e6f16eb3286d7619c69b90666d740ab815236a55fbfed04ee89ec658bbbbf12d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pybase64-1.0.0-cp35-cp35m-win32.whl
  • Upload date:
  • Size: 27.1 kB
  • Tags: CPython 3.5m, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/2.7.16

File hashes

Hashes for pybase64-1.0.0-cp35-cp35m-win32.whl
Algorithm Hash digest
SHA256 09c15c7f5ccd54b677a73dfc7a1e9b4b79840899608f3554d4da04fb028d1d07
MD5 48fe705aafbaf575896ce4523d28dda0
BLAKE2b-256 b577c83e91ddfc98937d3b59b73c3d284e6010f10d09ba4aeed803c6ee1ff54b

See more details on using hashes here.

File details

Details for the file pybase64-1.0.0-cp35-cp35m-manylinux1_x86_64.whl.

File metadata

  • Download URL: pybase64-1.0.0-cp35-cp35m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 62.6 kB
  • Tags: CPython 3.5m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.1

File hashes

Hashes for pybase64-1.0.0-cp35-cp35m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 9212d5d84c80d62667f24f7b27270118934b4bdb87b319fe0c16b37180a5a236
MD5 fcd0ef3102272dfb75b7b6832962ba3f
BLAKE2b-256 3fabd091f9f3ddc61b3fb279cce47b5b52faa146d725e73a41820ccd334f3e7b

See more details on using hashes here.

File details

Details for the file pybase64-1.0.0-cp35-cp35m-manylinux1_i686.whl.

File metadata

  • Download URL: pybase64-1.0.0-cp35-cp35m-manylinux1_i686.whl
  • Upload date:
  • Size: 58.5 kB
  • Tags: CPython 3.5m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.1

File hashes

Hashes for pybase64-1.0.0-cp35-cp35m-manylinux1_i686.whl
Algorithm Hash digest
SHA256 dc12b58c169052c31d5052b1619d2411b9999f8452b1a9128a8b4aa54cc69627
MD5 42e0dba651cb0c5bd7c3adf7338ca79b
BLAKE2b-256 2edaa0dc5b0c1f797ea269f42cc5a8b1122366acdbfc7ec1ec4885ba97c82828

See more details on using hashes here.

File details

Details for the file pybase64-1.0.0-cp35-cp35m-macosx_10_6_intel.whl.

File metadata

  • Download URL: pybase64-1.0.0-cp35-cp35m-macosx_10_6_intel.whl
  • Upload date:
  • Size: 40.1 kB
  • Tags: CPython 3.5m, macOS 10.6+ Intel (x86-64, i386)
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/2.7.14

File hashes

Hashes for pybase64-1.0.0-cp35-cp35m-macosx_10_6_intel.whl
Algorithm Hash digest
SHA256 5148986e7b9987f72586e0f86f897983c50f65e9c76e5660ac045a121d9c413d
MD5 c8c7b95dfd1c7a0a3dc8973cc4460607
BLAKE2b-256 8a28cddfc050d28e1cddd0e6c267438cdf2c8ca03858ee2a966e9665e5da4625

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