Skip to main content

Base32 encoding/decoding, RFC4648, RFC4648_HEX, Crockford

Project description

base32

Base32 encoding/decoding, RFC3548, RFC4648, RFC4648_HEX, Crockford

Installation

using pip

$ pip install base32_tiny

using poetry

$ poetry add base32_tiny

Usage

from base32_tiny.decode import decode
from base32_tiny.encode import encode


content = "hello, there!" 
#content_bytes = b"hello, there!"

result_rfc3548 = encode(content, variant="RFC3548")
print(result_rfc3548)  # output: NBSWY3DPFQQHI2DFOJSSC===
print(decode(result_rfc3548, variant="RFC3548").decode("utf-8") == content)  # output: True

result_rfc4648 = encode(content, variant="RFC4648")
print(result_rfc4648)  # output: NBSWY3DPFQQHI2DFOJSSC===
print(decode(result_rfc4648, variant="RFC4648"))  # output: b'hello, there!'


result_rfc4648_HEX = encode(content, variant="RFC4648-HEX")
print(result_rfc4648_HEX)  # output: D1IMOR3F5GG78Q35E9II2===
print(decode(result_rfc4648_HEX, variant="RFC4648-HEX"))  # output: b'hello, there!'


result_crockford = encode(content, variant="Crockford")
print(result_crockford)  # output: D1JPRV3F5GG78T35E9JJ2
print(decode(result_crockford, variant="Crockford"))  # output: b'hello, there!'

API Reference

def encode(data: Union[str, bytes], *, variant: Variant, options: Optional[Options] = None) -> str

def decode(input_str: str, variant: Variant) -> bytes

from typing import TypedDict, Literal
class Options(TypedDict, total=False):
    padding: bool
Variant = Literal["RFC3548", "RFC4648", "RFC4648-HEX", "Crockford"]

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

base32_tiny-0.1.0.tar.gz (2.8 kB view details)

Uploaded Source

Built Distribution

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

base32_tiny-0.1.0-py3-none-any.whl (4.1 kB view details)

Uploaded Python 3

File details

Details for the file base32_tiny-0.1.0.tar.gz.

File metadata

  • Download URL: base32_tiny-0.1.0.tar.gz
  • Upload date:
  • Size: 2.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.3

File hashes

Hashes for base32_tiny-0.1.0.tar.gz
Algorithm Hash digest
SHA256 731a24a54fbce8c525f09d4b08d8329179bf8d2b0ccd8fd1ee822397f28cb681
MD5 2f8ee11383dd68460dcd3a6472d02cb3
BLAKE2b-256 5c8a5d4b8892e1e703d0631fc9705f8a73d9f00740269472a34781f80e219901

See more details on using hashes here.

File details

Details for the file base32_tiny-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: base32_tiny-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 4.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.3

File hashes

Hashes for base32_tiny-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e43b20501616fe65656f1e473ae3d9d26b5c93eea35873e03a280faffc0a71ce
MD5 2e7ca34773423ce81c650e050544b2c0
BLAKE2b-256 26bc4c39ed56f4e759154eab77bcc5791c0eed804ba8608eefb674b65149fa8f

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