Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions multibase/multibase.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,16 @@ def __init__(self, encoding):
self.encoding = encoding
self._codec = ENCODINGS_LOOKUP[encoding]

@property
def code(self) -> bytes:
"""
The multibase prefix byte for this encoding.

:return: prefix byte
:rtype: bytes
"""
return self._codec.code

def encode(self, data):
"""
Encode data using this encoder's encoding.
Expand Down
1 change: 1 addition & 0 deletions tests/test_multibase.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ def test_encoder_class():
"""Test Encoder class."""
encoder = Encoder("base64")
assert encoder.encoding == "base64"
assert encoder.code == b"m"

encoded = encoder.encode("hello")
assert encoded.startswith(b"m")
Expand Down
Loading