Skip to main content

base64io

Latest Version Supported Python Versions Code style: black Documentation Status https://travis-ci.org/awslabs/base64io-python.svg?branch=master https://ci.appveyor.com/api/projects/status/ds8xvogp4m70j9ks?svg=true

This project is designed to develop a class, base64io.Base64IO, that implements a streaming interface for Base64 encoding.

Python has supported native Base64 encoding since version 2.4. However, there is no streaming interface for Base64 encoding, and none is available from the community.

The legacy base64.encode and base64.decode interface lets you shuffle data between two streams, but it assumes that you have two complete streams. We wanted a standard stream that applies Base64 encoding and decoding.

base64io.Base64IO provides an io streaming interface with context manager support that transparently Base64-encodes data read from it. You can use it to transform large files without caching the entire context in memory, or to transform an existing stream.

For the latest full documentation, see Read the Docs.

Find us on GitHub.

Getting Started

base64io.Base64IO has no dependencies other than the standard library and should work with any version of Python greater than 2.6. We test it on CPython 2.6, 2.7, 3.3, 3.4, 3.5, 3.6, and 3.7.

Installation

$ pip install base64io

Use

base64io.Base64IO wraps the input stream and transparently encodes or decodes data written to or read from the input stream.

  • write() encodes data before writing it to the wrapped stream

  • read() decodes data after reading it from the wrapped stream

Because the position of the base64io.Base64IO stream and the wrapped stream will almost always be different, base64io.Base64IO does not support:

  • seek()

  • tell()

Also, base64io.Base64IO does not support:

  • fileno()

  • truncate()

Encode data

from base64io import Base64IO

with open("source_file", "rb") as source, open("encoded_file", "wb") as target:
    with Base64IO(target) as encoded_target:
        for line in source:
            encoded_target.write(line)

Decode data

from base64io import Base64IO

with open("encoded_file", "rb") as encoded_source, open("target_file", "wb") as target:
    with Base64IO(encoded_source) as source:
        for line in source:
            target.write(line)

License

This library is licensed under the Apache 2.0 License.

Release files for base64io 1.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for base64io 1.0.1
File Size Uploaded
base64io-1.0.1.tar.gz 6.7 MB Details

Built distribution (wheel)

Table of built distributions (wheels) for base64io 1.0.1
File Interpreter ABI Platform
base64io-1.0.1-py2.py3-none-any.whl Python 2, Python 3 none any Details

Total release size: 6.8 MB

Release files / base64io-1.0.1.tar.gz

Download URL base64io-1.0.1.tar.gz
Size 6.7 MB
Tags Source
SHA-256 checksum
How to use checksums
8d322a9af0208aaa37639738876756f945efee48f62a6a22e40480099a0b2a20
BLAKE2b-256 checksum
How to use checksums
a010bd0bcd056295cb9efa24acc7a459b054d7da11454ecb3a2df4586e2b581d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / base64io-1.0.1-py2.py3-none-any.whl

Download URL base64io-1.0.1-py2.py3-none-any.whl
Size 16.9 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
fc6ce132c7fbac2e9a8db5db38d5419dda0e125c09674230e146fdf25b542a6e
BLAKE2b-256 checksum
How to use checksums
4059e57d1a132819d9ff9b96b1e86084df758edd57440d0dc32f5c00d0f1d775
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

1.0.3

2 release files

1.0.2

2 release files

This release

1.0.1 This release

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page