Python library to encode and decode pricklybird.
Project description
pypricklybird
Overview
pricklybird is a method for conversion of
arbitrary binary data into more human-friendly words,
where each word represents a single byte.
A CRC-8 checksum is attached to allow the detection of errors during decoding.
0xDEADBEEF becomes turf-port-rust-warn-void, for example.
pypricklybird is a python implementation of pricklybird version v1.
Documentation
Documentation is generated using pdoc and can be found here.
Usage
Basic conversion functions that fully comply with the specification and include the CRC can be used as follows.
>>> from pypricklybird import convert_to_pricklybird, convert_from_pricklybird
>>> data = bytearray.fromhex("4243")
>>> code = convert_to_pricklybird(data);
>>> code # Notice the third word "full" used to encode the CRC.
'flea-flux-full'
>>> convert_from_pricklybird(code).hex()
'4243'
It is also possible to map word to bytes and bytes to words without the full standard implementation and CRC.
>>> from pypricklybird import words_to_bytes, bytes_to_words
>>> data = bytearray.fromhex("4243")
>>> words = bytes_to_words(data)
>>> words # Notice that no CRC is attached
['flea', 'flux']
>>> words_to_bytes(words).hex()
'4243'
Direct access to the WORDLIST used for mapping bytes to words,
and the HASH_TABLE use to map words to bytes is also possible.
>>> from pypricklybird import WORDLIST, HASH_TABLE, word_hash
>>> # Confirm that the word flux maps to the byte 0x43 in both directions.
>>> word = "flux"
>>> table_index = word_hash(word[0], word[-1]);
>>> table_index
603
>>> byte_value = HASH_TABLE[table_index]
>>> hex(byte_value)
'0x43'
Installation
pip install pypricklybird
License
pypricklybird is distributed under the terms of the MIT license.
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pypricklybird-1.0.3.tar.gz.
File metadata
- Download URL: pypricklybird-1.0.3.tar.gz
- Upload date:
- Size: 7.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6c41a1bb0c16025d0672f1c82cbfda561a812db9178620bc2e3613dd45e8aac2
|
|
| MD5 |
1bfcbc05a19f7887065980875d63bbd7
|
|
| BLAKE2b-256 |
7fb7b3a5f4352f4d755cef10e726e30fd978cde7645eae354ee57672d704499d
|
File details
Details for the file pypricklybird-1.0.3-py3-none-any.whl.
File metadata
- Download URL: pypricklybird-1.0.3-py3-none-any.whl
- Upload date:
- Size: 7.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
812505f0f77a991ceb5140495794eb4b1f8a7247dee7ef57aee1a799b0387c38
|
|
| MD5 |
d815c6993ed6ec57c78cff5bfbf6a685
|
|
| BLAKE2b-256 |
2542adce78ffb8953a016c50fb72601254ca358b1fb5ec36fb2f69e186661e0b
|