Skip to content
This repository has been archived by the owner on May 9, 2023. It is now read-only.

multiformats/py-multibase

Repository files navigation

This project is no longer maintained and has been archived.

py-multibase

https://img.shields.io/travis/multiformats/py-multibase.svg?branch=master Documentation Status

Multibase implementation for Python

Multibase is a protocol for distinguishing base encodings and other simple string encodings, and for ensuring full compatibility with program interfaces.

It answers the question: Given data d encoded into string s, how can I tell what base d is encoded with?

Base encodings exist because transports have restrictions, use special in-band sequences, or must be human-friendly. When systems chose a base to use, it is not always clear which base to use, as there are many tradeoffs in the decision. Multibase is here to save programs and programmers from worrying about which encoding is best.

It solves the biggest problem: a program can use multibase to take input or produce output in whichever base is desired.

The important part is that the value is self-describing, letting other programs elsewhere know what encoding it is using.

Installation

$ pip install py-multibase

Sample Usage

>>> # encoding a buffer
>>> from multibase import encode, decode
>>> encode('base58btc', 'hello world')
b'zStV1DL6CwTryKyV'
>>> encode('base64', 'hello world')
b'mGhlbGxvIHdvcmxk'
>>> # decoding a multibase
>>> decode('mGhlbGxvIHdvcmxk')
b'hello world'
>>> decode(b'zStV1DL6CwTryKyV')
b'hello world'
>>> decode(encode('base2', b'hello world'))
b'hello world'

Supported codecs

  • base2
  • base8
  • base10
  • base16
  • base16
  • base16
  • base32hex
  • base32
  • base32z
  • base36
  • base36upper
  • base58flickr
  • base58btc
  • base64
  • base64url

About

Multibase implementation in Python

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •