Fast Base64 encoding/decoding
Project description
Fast Base64 implementation
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.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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Hashes for pybase64-0.3.0-cp36-cp36m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1e8055ae86b64e3aa36205f6602194f08f5a701b7fd98c0959a4f98797e5e199 |
|
MD5 | 1d85b5ff3d7a2c09c8ba86477c1d87ce |
|
BLAKE2b-256 | 645c1a60bc55f227da0f085af971b3c7bfd8221f9a2642de588a83f73eb26539 |
Hashes for pybase64-0.3.0-cp36-cp36m-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e3b1ef72c558db92a5b85a6bf84d170381ec26e840642eed4dc04bd38d539229 |
|
MD5 | 938cfa7a08b414a71e34af13a66d92aa |
|
BLAKE2b-256 | 5a85a592852a5038599ceb404d098a9e05e8a5ad60f043282fec98fcccf1508e |
Hashes for pybase64-0.3.0-cp36-cp36m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9c31bc995820f350ac1c4574b476034cfc6b746679a0c405cbb8329f964aa094 |
|
MD5 | dfd084ce412a45df669407e86c1de1b8 |
|
BLAKE2b-256 | 8702ca06e817ccc89c8072f451e8ee4bc59691238cdea5784fe739dad504195b |
Hashes for pybase64-0.3.0-cp36-cp36m-manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f2f2fda2378a569e89aa3799da31214736888f581ecbba30ac51404ab9bbfd31 |
|
MD5 | a5ea0966af9e875338c5cc660aaac284 |
|
BLAKE2b-256 | b3d8998ee4268eb7313fe369b7bc23710bb55ac66b1c9e4df3fd97abdba2903e |
Hashes for pybase64-0.3.0-cp36-cp36m-macosx_10_6_intel.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3cfe39ad950e7db8d28d7c2ebbdf314fb3e1d01fb7fcbc8d75c256ce1b1f7f8e |
|
MD5 | 4cfc49f6783e23a41534f2e7ed2487dd |
|
BLAKE2b-256 | 9a25d4801dc45c016d78599e5d865c87e4b61339122b80c4f4e1ee4c3bb492f7 |
Hashes for pybase64-0.3.0-cp35-cp35m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8537643dd68076f4ada7a537d19597b521c6a727768d446f74ee3ad8177ecec7 |
|
MD5 | cc70de77830dc4eaa7554373080ac2b2 |
|
BLAKE2b-256 | edea7b43da15d659fdd434a54c332303e68219133eb7f8f9ced41aebce4686c0 |
Hashes for pybase64-0.3.0-cp35-cp35m-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4e47feb2ea22bb5830772b0ad7d1dd492fd89a8812ef2bb2196f289416231133 |
|
MD5 | 9469441ab77d2f681efd4d55a39a8248 |
|
BLAKE2b-256 | 48554eea8f0518c9413e7d4b40d78d4091577eb51bc859f4afdb87d9254472d9 |
Hashes for pybase64-0.3.0-cp35-cp35m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2ee8335583c0fa00443c0cc78f44e4696f1cd26885a1a9eb4484b1e0e054ff07 |
|
MD5 | 404ce9262c242f0e97c87365f5da9b34 |
|
BLAKE2b-256 | 6de74dfb5b7cead3204a0e95114e2b5142f924d6e5c4ae5d4e63ab61d80ea767 |
Hashes for pybase64-0.3.0-cp35-cp35m-manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cd37f74b1f35115919745e4ae9d2ba270d5eadcf31781185bf2d766f417be3bd |
|
MD5 | c55ebb50b6aea3ee2ce6eff2e692aa44 |
|
BLAKE2b-256 | 2b7aaa6b2ab63a76e93052034cb1a1a1217fdc6a60447f8b3c9be6dc64a2c2fc |
Hashes for pybase64-0.3.0-cp35-cp35m-macosx_10_6_intel.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ef30dca87d11c23a57468adb01f32355a21408922cde4be983bd58dab5e38c23 |
|
MD5 | c5edc68434bac96d63133403e216c8ba |
|
BLAKE2b-256 | d0dc0383824b62e40e6141d9626f695c327bfa4da56f629126a519bf275ae1e4 |
Hashes for pybase64-0.3.0-cp34-cp34m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a525536312e12d6e5411c6e213f477f6330cd8bd64f435827e37e1604f5a2d7b |
|
MD5 | c1e6d745fe3cf0c32b827758380df641 |
|
BLAKE2b-256 | c0335ea570fa0671d69bbc8d4bda938840b97de5cca1bd61885e3221853b27d0 |
Hashes for pybase64-0.3.0-cp34-cp34m-manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 996b7c4b1564e8472e1d83a79f0339e4eaf1016b0760090cd60ae600db305026 |
|
MD5 | 136a4ee93097fe73d94c27cf2c4c3e87 |
|
BLAKE2b-256 | 701afd266807cdadf630f7598adfa7ac9a0e0c1a460246970acb48da707a54f0 |
Hashes for pybase64-0.3.0-cp34-cp34m-macosx_10_6_intel.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cb537719defbe0b5cc175cca0a37ff37688beb551a06c6d9789e36258c45862d |
|
MD5 | 02b1990d36aa8883788499499dce2cf7 |
|
BLAKE2b-256 | 10af103320572d6e17fee57eaec4fcf8deda3f93f40cb9dc8361a580ccffe474 |
Hashes for pybase64-0.3.0-cp33-cp33m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bf6186212401859757899eee9915227d07e2050bd69c2c0e90a2d2a716eb284c |
|
MD5 | 5bad760f7b023e3408954281f9a630fe |
|
BLAKE2b-256 | 10a6e5daa89a255a7bc95235cbeb630ff554b204929946792b42f9749e0c95b1 |
Hashes for pybase64-0.3.0-cp33-cp33m-manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6594cd5fa300ef324243aad6b2a96f0a0f7ac261a9ad6726cde74b838e183eb8 |
|
MD5 | db23fa68c439439f0295ebfe01ad03be |
|
BLAKE2b-256 | e295bf3ab3a9fe1ac469c6445d52dd3a72fb44362257686fba02a2dec4e1352c |
Hashes for pybase64-0.3.0-cp27-cp27mu-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 96f04fbe54155d9c07e3ce5f82d896043de49b928b692c3bc2dd6efccd4e5744 |
|
MD5 | 92eb13442c47cbddb9611fc547e4ae56 |
|
BLAKE2b-256 | a4138cc30c66c2b8570daf3e02e22711d95415835fd63bf7d51e294f7cfb3f6e |
Hashes for pybase64-0.3.0-cp27-cp27mu-manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e9247aba66d5c03ef197b0b3142298559683bc9cd2dd9f6ca533609de840e4b5 |
|
MD5 | 6e62b2e084233949eadf2f1ad4c73c65 |
|
BLAKE2b-256 | 26b4cbe20cf200052128d9284c8e76bcd9cbcfcc2be107a892a99cf53b17ec49 |
Hashes for pybase64-0.3.0-cp27-cp27m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b00182d0345e3dee9d5c9eb6289474191f6e42ce7b272d641c6a23dae9384d45 |
|
MD5 | 134fb02ef75ada33cbac220e26de6d0d |
|
BLAKE2b-256 | 67fec21b5deebd5717c48b04a026be84bfad9068e0911f3c26287882a70ae666 |
Hashes for pybase64-0.3.0-cp27-cp27m-manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | aaad05a7feab13e8db3a6cd9a0ca2492cb4801c23e75383ae4eed9a0cb23de12 |
|
MD5 | 8d47273e9d9ed90926d1891de2f5a95b |
|
BLAKE2b-256 | cc7e26bc4dc317c24ab03272034342e81e1475dd9b555d6aeab965aaac746e3d |
Hashes for pybase64-0.3.0-cp27-cp27m-macosx_10_6_intel.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 84599c55025524c05af3f102b43a5e34e40a239473f492f3131e2ee41533f630 |
|
MD5 | bc1ae0ec89e06d4d79f4e9794b191364 |
|
BLAKE2b-256 | 467b5a92367e25c39f306f4646b20c69459c81d6540a5a811aae6ace2aa12f37 |