z-base32 encoder
The snippet can be accessed without any authentication.
Authored by
Frank Sauerburger
Python 3 compatible, pure-Python implementation of z-base-32 based on Python's base64 module.
import base64
original_alph = b"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"
zbase_alph = b"ybndrfg8ejkmcpqxot1uwisza345h769"
encode_trans = bytes.maketrans(original_alph, zbase_alph)
decode_trans = bytes.maketrans(zbase_alph, original_alph)
def encode(value):
"""Encode the given value in zbase32"""
encoded = base64.b32encode(value)
return encoded.translate(encode_trans)
def decode(value):
"""Decode a zbase32-encoded value"""
translated = value.translate(decode_trans)
return base64.b32decode(translated)
Please register or sign in to comment