Skip to main content

A Python implementation of the Rune-512 encoding and decoding algorithm.

Project description

Rune-512: Compact Binary Encoding

PyPI version License: MIT

Rune-512 is a binary-to-text encoding scheme designed to safely and compactly embed arbitrary binary data in environments with strict character limits but also support a wide range of Unicode characters, such as social media bios (like Bluesky, Twitter).

It uses a carefully selected 512-character symbolic unicode alphabet that is not visually distracting and can represent data more densely than traditional encodings like Base64, packing 9 bits of data into a single character.

For example, here's 32 random bytes:

ᛝ⠅┯⡊⡋⢜⢴⣗▮⢌▟⣣┘▊⡼╋⢱⣜▧⣎━▋◰╾╧□⠜◡⢎⣙⠴▀

Here's the string "the fox jumped over the lazy dog":

ᛝ⠟ ⡋⡑◣┦◻⢥┇⡖⠑⢡┇◗╊◞┪┹⢦◈◠┍⡬⢅⣇┤⡻⠶⠡⠨⡳⢿◣⡂◎◱⢩▵⣡⢊⣛⡉⣖⠔┭⣣○⣛┃⢒┯⡫╧⠲▊◃▲⣷⠹⢠

Features

  • Compact: Encodes 9 bits per character, offering significant space savings over Base64.
  • Reliable: Uses a CRC-16 checksum to detect data corruption.
  • Safe: The alphabet consists of Unicode codepoints with wide compatibility across common platforms.
  • Easy to Use: Provides a simple command-line interface and a straightforward Python library.

Installation

Install rune-512 from PyPI:

pip install rune-512

Usage

Command-Line Interface

The package provides a CLI for easy encoding and decoding from your terminal.

Encoding

To encode a string:

python -m rune_512 encode "hello world"
# Output: ᛝ⠻◈□┫⣆▍◈⠻╯⣤▱┠

To encode a hex string, use the --hex flag:

python -m rune_512 encode --hex "deadbeef"
# Output: ᛝ⣄⢯╺╭◮◠

You can also pipe data from stdin:

echo "some data" | python -m rune_512 encode
# Output: ᛝ⠘⡴◍╻⣖⢤⠙⠰╴⣂

Decoding

To decode a rune-512 string:

python -m rune_512 decode "ᛝ⠻◈□┫⣆▍◈⠻╯⣤▱┠"
# Output: hello world

To decode to a hex string, use the --hex flag:

python -m rune_512 decode --hex "ᛝ⣄⢯╺╭◮◠"
# Output: deadbeef

Python Library

You can also use rune-512 directly in your Python code.

from rune_512 import encode, decode

# Simple payload
payload = b'hello world'
encoded = encode(payload)
print(f"Encoded: {encoded}")

decoded = decode(encoded)
print(f"Decoded: {decoded.decode()}")

# More complex payload
complex_payload = b'\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f'
encoded_complex = encode(complex_payload)
print(f"Encoded complex: {encoded_complex}")

decoded_complex = decode(encoded_complex)
assert decoded_complex == complex_payload

How It Works

A rune-512 encoded string consists of three parts:

  1. Magic Prefix (): A special character that identifies the string as rune-512 encoded data.
  2. Header: A 17-bit section containing a 16-bit CRC-16/XMODEM checksum of the original payload and a parity bit for padding disambiguation.
  3. Payload: The binary data, packed into 9-bit chunks.

Each 9-bit chunk is mapped to a character in the 512-character alphabet. This structure ensures that the data is both compact and verifiable.

License

This project is licensed under the MIT License. See the LICENSE file for details.

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

rune_512-0.1.1.tar.gz (10.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

rune_512-0.1.1-py3-none-any.whl (7.4 kB view details)

Uploaded Python 3

File details

Details for the file rune_512-0.1.1.tar.gz.

File metadata

  • Download URL: rune_512-0.1.1.tar.gz
  • Upload date:
  • Size: 10.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.3

File hashes

Hashes for rune_512-0.1.1.tar.gz
Algorithm Hash digest
SHA256 2cf6c21ac0acbfcf7fca9d4b7528960e0657f03afca9992188a671ae29ef772d
MD5 3946f7f1bb9ccc78afe7621e55c2b981
BLAKE2b-256 95175c213baf388e2f5bea3e9b7a888a5388c9c3f9470847f36db7b5b0250be7

See more details on using hashes here.

File details

Details for the file rune_512-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: rune_512-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 7.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.3

File hashes

Hashes for rune_512-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 ebb14ebf7e238570c4a5cb9627f21d1f133a88f5a01e2a28b1d780a1d8eaf2b5
MD5 33fd49540f13c2f79dd942fa05a9b7b9
BLAKE2b-256 f9bac9bf9640d5a89e28d1dd943087062a273edc19f236da46470163d445f9bd

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page