| Crates.io | b256 |
| lib.rs | b256 |
| version | 0.4.1 |
| created_at | 2025-09-18 13:26:00.390247+00 |
| updated_at | 2025-09-19 09:56:29.189715+00 |
| description | Dense byte to unicode character encoding |
| homepage | |
| repository | https://github.com/rotkonetworks/b256 |
| max_upload_size | |
| id | 1844720 |
| size | 26,071 |
Dense byte-to-unicode encoding. 32 bytes → 32 characters.
// Before: Debug output for [u8; 32]
[58, 216, 165, 65, 124, 141, 110, 247, 71, 125, 151, 247, 52, 203, 133, 41,
110, 37, 2, 225, 199, 129, 236, 58, 239, 142, 11, 154, 90, 205, 222, 11]
// After: base256 encoding
ЩóΓÎLÄμöÊLχ9ρÞ4ωÒmiЁBøάЩηÄθÓψÏÇΔa
Library:
cargo add b256
CLI:
cargo install b256
Library:
use b256::Base256;
// Basic encoding/decoding
let key = [0u8; 32];
let encoded = Base256::encode(&key); // 111111111111111111111111111111111
let decoded = Base256::decode(&encoded).unwrap();
// String parsing (new in 0.4.0)
let valid = Base256::is_valid("ЩóΓÎLÄμöÊLχ9ρÞ4ωÒmiЁBøάЩηÄθÓψÏÇΔa");
let bytes = Base256::parse("ЩóΓÎLÄμöÊLχ9ρÞ4ωÒmiЁBøάЩηÄθÓψÏÇΔa").unwrap();
// Hex conversions
let hex_bytes = Base256::to_hex(&encoded).unwrap(); // [48, 48, 48, ...] (64 bytes)
let from_hex = Base256::from_hex(&hex_bytes).unwrap(); // back to base256
// Direct byte-hex conversions
let hex = Base256::bytes_to_hex(&key); // "0000...0000" as bytes
let bytes = Base256::hex_to_bytes(&hex).unwrap();
CLI:
# Encode stdin to base256 (default)
head -c 32 /dev/urandom | base256
# Decode base256 to raw bytes
echo 'ЩóΓÎLÄμöÊLχ9ρÞ4ωÒmiЁBøάЩηÄθÓψÏÇΔa' | base256 -d | xxd
# Encode to hex
head -c 32 /dev/urandom | base256 -x
# Convert hex to base256
echo '3ad8a5417c8d6ef7477d97f734cb85296e2502e1c781ec3aef8e0b9a5acdde0b' | base256 -X
# Convert base256 to hex
echo 'ЩóΓÎLÄμöÊLχ9ρÞ4ωÒmiЁBøάЩηÄθÓψÏÇΔa' | base256 -dx
# SSH public key to base256
awk '{print $2}' ~/.ssh/id_ed25519.pub | base64 -d | tail -c32 | base256
[char; 32] arrays, not variable-length stringsCharacter set (256 total):
Use base256 for:
Use hex for:
# Generate ed25519 public key identifier
openssl genpkey -algorithm ed25519 | \
openssl pkey -pubout -outform DER | \
tail -c32 | \
base256
# Output: sοΤQÞвύώБρÄUÁπΨQΞeRϊyϏjϋнХÀēāÄnт
# Compare all encodings
KEY=$(head -c32 /dev/urandom)
echo "$KEY" | base256 # 32 chars: ΓΨΒωυ...
echo "$KEY" | base64 # 44 chars: P6iy1p...==
echo "$KEY" | xxd -p # 64 chars: 3ad8a5...
MIT OR Apache-2.0