Skip to main content

Fast Base64 encoding/decoding

Project description

Fast Base64 implementation

license-status pypi-status 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.6.0, Apple LLVM version 9.1.0 (clang-902.0.39.1), Mac OS X 10.13.3 on an Intel Core i7-4870HQ @ 2.50GHz

pybase64 0.3.0 (C extension active - AVX2)
bench: altchars=None, validate=False
pybase64._pybase64.encodebytes:   1671.633 MB/s (13,271,472 bytes -> 17,928,129 bytes)
pybase64._pybase64.b64encode:     3355.630 MB/s (13,271,472 bytes -> 17,695,296 bytes)
pybase64._pybase64.b64decode:      313.357 MB/s (17,695,296 bytes -> 13,271,472 bytes)
base64.encodebytes:                 84.229 MB/s (13,271,472 bytes -> 17,928,129 bytes)
base64.b64encode:                  594.513 MB/s (13,271,472 bytes -> 17,695,296 bytes)
base64.b64decode:                  316.510 MB/s (17,695,296 bytes -> 13,271,472 bytes)
bench: altchars=None, validate=True
pybase64._pybase64.b64encode:     3447.100 MB/s (13,271,472 bytes -> 17,695,296 bytes)
pybase64._pybase64.b64decode:     3513.827 MB/s (17,695,296 bytes -> 13,271,472 bytes)
base64.b64encode:                  592.162 MB/s (13,271,472 bytes -> 17,695,296 bytes)
base64.b64decode:                  103.155 MB/s (17,695,296 bytes -> 13,271,472 bytes)
bench: altchars=b'-_', validate=False
pybase64._pybase64.b64encode:     2440.743 MB/s (13,271,472 bytes -> 17,695,296 bytes)
pybase64._pybase64.b64decode:      285.376 MB/s (17,695,296 bytes -> 13,271,472 bytes)
base64.b64encode:                  344.905 MB/s (13,271,472 bytes -> 17,695,296 bytes)
base64.b64decode:                  224.162 MB/s (17,695,296 bytes -> 13,271,472 bytes)
bench: altchars=b'-_', validate=True
pybase64._pybase64.b64encode:     2566.995 MB/s (13,271,472 bytes -> 17,695,296 bytes)
pybase64._pybase64.b64decode:     2522.613 MB/s (17,695,296 bytes -> 13,271,472 bytes)
base64.b64encode:                  342.011 MB/s (13,271,472 bytes -> 17,695,296 bytes)
base64.b64decode:                   89.865 MB/s (17,695,296 bytes -> 13,271,472 bytes)

Changelog

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-0.3.1.tar.gz (80.0 kB view details)

Uploaded Source

Built Distributions

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

pybase64-0.3.1-cp36-cp36m-win_amd64.whl (28.6 kB view details)

Uploaded CPython 3.6mWindows x86-64

pybase64-0.3.1-cp36-cp36m-win32.whl (26.6 kB view details)

Uploaded CPython 3.6mWindows x86

pybase64-0.3.1-cp36-cp36m-manylinux1_x86_64.whl (64.1 kB view details)

Uploaded CPython 3.6m

pybase64-0.3.1-cp36-cp36m-manylinux1_i686.whl (60.0 kB view details)

Uploaded CPython 3.6m

pybase64-0.3.1-cp36-cp36m-macosx_10_6_intel.whl (39.1 kB view details)

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

pybase64-0.3.1-cp35-cp35m-win_amd64.whl (28.6 kB view details)

Uploaded CPython 3.5mWindows x86-64

pybase64-0.3.1-cp35-cp35m-win32.whl (26.6 kB view details)

Uploaded CPython 3.5mWindows x86

pybase64-0.3.1-cp35-cp35m-manylinux1_x86_64.whl (64.1 kB view details)

Uploaded CPython 3.5m

pybase64-0.3.1-cp35-cp35m-manylinux1_i686.whl (60.0 kB view details)

Uploaded CPython 3.5m

pybase64-0.3.1-cp35-cp35m-macosx_10_6_intel.whl (39.1 kB view details)

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

pybase64-0.3.1-cp34-cp34m-manylinux1_x86_64.whl (63.9 kB view details)

Uploaded CPython 3.4m

pybase64-0.3.1-cp34-cp34m-manylinux1_i686.whl (59.8 kB view details)

Uploaded CPython 3.4m

pybase64-0.3.1-cp34-cp34m-macosx_10_6_intel.whl (39.0 kB view details)

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

pybase64-0.3.1-cp33-cp33m-manylinux1_x86_64.whl (63.5 kB view details)

Uploaded CPython 3.3m

pybase64-0.3.1-cp33-cp33m-manylinux1_i686.whl (59.4 kB view details)

Uploaded CPython 3.3m

pybase64-0.3.1-cp27-cp27mu-manylinux1_x86_64.whl (63.4 kB view details)

Uploaded CPython 2.7mu

pybase64-0.3.1-cp27-cp27mu-manylinux1_i686.whl (59.2 kB view details)

Uploaded CPython 2.7mu

pybase64-0.3.1-cp27-cp27m-manylinux1_x86_64.whl (63.4 kB view details)

Uploaded CPython 2.7m

pybase64-0.3.1-cp27-cp27m-manylinux1_i686.whl (59.2 kB view details)

Uploaded CPython 2.7m

pybase64-0.3.1-cp27-cp27m-macosx_10_6_intel.whl (39.0 kB view details)

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

File details

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

File metadata

  • Download URL: pybase64-0.3.1.tar.gz
  • Upload date:
  • Size: 80.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for pybase64-0.3.1.tar.gz
Algorithm Hash digest
SHA256 c974bff394e16817596fab686a0c7deb4995a468b035b02a788b6dbfd1e6bdeb
MD5 8777c9b06f704c6bce452872f10708df
BLAKE2b-256 1a846b605c6b6d6b49c81d27961e796a8c87dae617e83f4ba1f46922ce11bf16

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pybase64-0.3.1-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 82ea36095614c57ded583e8db2a5cee2695fd33a989616e013b0e8c370054df1
MD5 428b757712290e961540a429fa6104ac
BLAKE2b-256 36a901df393ca151295a87a567c795e307d024b54a7115dce7fab16195f5a075

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pybase64-0.3.1-cp36-cp36m-win32.whl
Algorithm Hash digest
SHA256 ceb6845c087bc453a92edf8e790f7cbd4aa5d2f6a9956e46e7f1a6423d7a6292
MD5 edae4512f8c23c808d2416019bd8c7e6
BLAKE2b-256 55944573a0a525df0f4296c53c8f5f1fb57823058169e194bbdc4748e836e348

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pybase64-0.3.1-cp36-cp36m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 d100b5f7e2cc94ab58ec3c2537798aa448cfae5058cf59cb678089f22179d078
MD5 0cbb8df25cdba2893fb4d7570a144599
BLAKE2b-256 a2e66c73da0df714a581ad4787aa6903296358f979169561ea291879e1ad51c4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pybase64-0.3.1-cp36-cp36m-manylinux1_i686.whl
Algorithm Hash digest
SHA256 1d8b30387847d4a1b4b5341cafaeb56a6a7ce6f499f4b6cb67bb9fc7c1325614
MD5 d9a6d6b1b9360089f5771465720c1bc6
BLAKE2b-256 d9fdfc2f94ee0a59ecd3db454ade113fb99fa7160a6c3c34cc68073fcb343ce8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pybase64-0.3.1-cp36-cp36m-macosx_10_6_intel.whl
Algorithm Hash digest
SHA256 56ee9b40b91caa73d3c5c3e5c8816115b46b4c17f29ada9720b768d27cce3810
MD5 05c1f6a02783dfab475a4027dc026324
BLAKE2b-256 2d7c6ab9ffc3abc9bc57cb9b2f482ab564ccc93c8b057c6320be253cb2d6be43

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pybase64-0.3.1-cp35-cp35m-win_amd64.whl
Algorithm Hash digest
SHA256 1628ce3070de682d49414359a09cc4d1313f40f42df37df34ab72a462699f09b
MD5 1ea18eceffdafab3aeaaccd6b8141dff
BLAKE2b-256 39dd831da77b21bd831646a50bdf398e96bbda304766d0057a651069cc04c84b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pybase64-0.3.1-cp35-cp35m-win32.whl
Algorithm Hash digest
SHA256 a8e8d421ce4894df5d6a961758e67f9a2c1dd9c02730576e84877c406c207699
MD5 190d19649c6a2443d696ddbe603e97e7
BLAKE2b-256 9407e3c78268e14a59a77fdf2a9a4bca71cfd951dc6273c4d8d6c197a89cfcf0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pybase64-0.3.1-cp35-cp35m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 269e8b42d91843baa3427b3b2f6a9c4c7d34b818cdbd2a66a62229e7c2077dcb
MD5 f44bdf3679e478115b7e0afde3552b0b
BLAKE2b-256 07c1c5f5c4f35d1e821a0c461f2acdaa4b982ac120c70e4efe042ed80308a038

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pybase64-0.3.1-cp35-cp35m-manylinux1_i686.whl
Algorithm Hash digest
SHA256 41af81226fae4442dcabd28ac90fa71a552963aad1d6926e696a8c860ac8948d
MD5 7a7d0478d87c12c067c7d64b422ce27e
BLAKE2b-256 2b6f5a74c40a2e6ec0237db4008e5253b0d60d449fed073ee452cc1572ff85ab

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pybase64-0.3.1-cp35-cp35m-macosx_10_6_intel.whl
Algorithm Hash digest
SHA256 9803154aea31b4f44758ad9f0168a24f401723ef147238938af450494f63a24b
MD5 9b995e6af60b822b1717805cf55d6e52
BLAKE2b-256 740626eaf31cc32ec5a986b7f2dbc26d673d391a7e6cd043a5df6966c88bd2da

See more details on using hashes here.

File details

Details for the file pybase64-0.3.1-cp34-cp34m-manylinux1_x86_64.whl.

File metadata

File hashes

Hashes for pybase64-0.3.1-cp34-cp34m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 cda55aa7202267d81f7465a2a40e95341d2a223cd654c3922b847c9bd28f181b
MD5 913987f57acabec8639f1f102b6f4f60
BLAKE2b-256 c36b179db911551858e02e684d39f6830d5549f3e4c2c98c24d26104267802a3

See more details on using hashes here.

File details

Details for the file pybase64-0.3.1-cp34-cp34m-manylinux1_i686.whl.

File metadata

File hashes

Hashes for pybase64-0.3.1-cp34-cp34m-manylinux1_i686.whl
Algorithm Hash digest
SHA256 28e3dc7b4d5c3c10eb484cb36dfe753963a3a9f11e28e0ae68ee7c4099b97160
MD5 4d8e5192d1738a3a888ec5e1c3fb6fe7
BLAKE2b-256 11539237c055680de3940b57327a266cade5933a3a3a24a32d374127b3d1d46d

See more details on using hashes here.

File details

Details for the file pybase64-0.3.1-cp34-cp34m-macosx_10_6_intel.whl.

File metadata

File hashes

Hashes for pybase64-0.3.1-cp34-cp34m-macosx_10_6_intel.whl
Algorithm Hash digest
SHA256 7c3fa02b73059d8be2b254d7c4429de028a162cfe257ff9bb03b8baf77ad54cb
MD5 dc4905f95ceb1869f385d4d3489d6883
BLAKE2b-256 443a7e17622286b9db513481a7b5071974fc9d36c0067b775c1d2c55a44cd128

See more details on using hashes here.

File details

Details for the file pybase64-0.3.1-cp33-cp33m-manylinux1_x86_64.whl.

File metadata

File hashes

Hashes for pybase64-0.3.1-cp33-cp33m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 80b3192fb9385d1bc73c725ebd17762b53aaefab61b9fcc77170d94b6c348990
MD5 b8ecc04f65806576aa930fdadb34f555
BLAKE2b-256 1484e060b1cfdff7df153c2ecbeec3c68c1c84e5fc07965217d7e6ac93a199d8

See more details on using hashes here.

File details

Details for the file pybase64-0.3.1-cp33-cp33m-manylinux1_i686.whl.

File metadata

File hashes

Hashes for pybase64-0.3.1-cp33-cp33m-manylinux1_i686.whl
Algorithm Hash digest
SHA256 0451b897b485d97cda6c53b7d60c9ba1fdd4d9ec37d5cf3f21bd5b8e0c50d34a
MD5 9c11369f3f2cbda6a1804644c997ad34
BLAKE2b-256 48ad71c7111cbe55efb516ccc3a4e7a56d38b7d1238f371fb1c83b2ee0dfe823

See more details on using hashes here.

File details

Details for the file pybase64-0.3.1-cp27-cp27mu-manylinux1_x86_64.whl.

File metadata

File hashes

Hashes for pybase64-0.3.1-cp27-cp27mu-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 cbd5e02fc586e45eecf6b857017156d061374bac3ff324871fb8e3e6812421c8
MD5 4a76a1d326c930dd009f7e74b48af17a
BLAKE2b-256 7882ba4f5b1b5291177f9cd5e290f006e0795e52cf0cde8989bd0ee13d54205d

See more details on using hashes here.

File details

Details for the file pybase64-0.3.1-cp27-cp27mu-manylinux1_i686.whl.

File metadata

File hashes

Hashes for pybase64-0.3.1-cp27-cp27mu-manylinux1_i686.whl
Algorithm Hash digest
SHA256 a59191c8087246fc922344136af989413e3cbfae053eef3971a3161abc62d965
MD5 7c2fa093e3e92751406c466a01e01979
BLAKE2b-256 5c5b8d2f31d82fe3e721ff94c6bca9e343df32a6345edaa920e4ec54f49d90b1

See more details on using hashes here.

File details

Details for the file pybase64-0.3.1-cp27-cp27m-manylinux1_x86_64.whl.

File metadata

File hashes

Hashes for pybase64-0.3.1-cp27-cp27m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 ff956bb29132817d272495235a984f3f1d2085b6a9f071ed4f8b40e3aef3f5db
MD5 e730e23e0d1dbf977654e9106a2dd52a
BLAKE2b-256 2af12868fb6cced99fc953c8cff927b2fcfd7d7d070497f5c3bdd0e8ba02f53a

See more details on using hashes here.

File details

Details for the file pybase64-0.3.1-cp27-cp27m-manylinux1_i686.whl.

File metadata

File hashes

Hashes for pybase64-0.3.1-cp27-cp27m-manylinux1_i686.whl
Algorithm Hash digest
SHA256 2effb9417d88344640d084e4196cdb25f28bce6229768919cd7b4aa942231d5f
MD5 5961e279b407eaa2b2f3e47c270d0aba
BLAKE2b-256 5445494a65eda798320b0648d384c71c7782a3e62128524bbcd9539543d28ba8

See more details on using hashes here.

File details

Details for the file pybase64-0.3.1-cp27-cp27m-macosx_10_6_intel.whl.

File metadata

File hashes

Hashes for pybase64-0.3.1-cp27-cp27m-macosx_10_6_intel.whl
Algorithm Hash digest
SHA256 2872410e56866357a8f5264218c80020de3c1bf61632fc8cc7a2ca7285fa0906
MD5 be24398ba5ecd64c9f64db8c6cbc7813
BLAKE2b-256 feec555e9ac1372299290ac732356c5a1a7ae04fda9b1914a9a2c2ed5840aadf

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