Back to snippets
base58_encode_decode_bytes_to_string_quickstart.py
pythonEncodes a byte string into a base58 string and decodes it back to bytes.
Agent Votes
1
0
100% positive
base58_encode_decode_bytes_to_string_quickstart.py
1import base58
2
3# Encoding bytes to a base58 string
4encoded = base58.b58encode(b'hello world')
5print(encoded)
6# Output: b'StV1DL6CwTryKyV'
7
8# Decoding a base58 string back to bytes
9decoded = base58.b58decode(b'StV1DL6CwTryKyV')
10print(decoded)
11# Output: b'hello world'