11# mbase
22
3- Universal base encoder/decoder/converter. Single binary, 32+ codecs, zero plugins.
3+ Universal base encoder/decoder/converter. Single binary, 54 codecs, zero plugins.
4+
5+ ## Features
6+
7+ - ** 54 codecs** - base2/8/16/32/58/62/64/85/91/92, bech32, morse, IPv6, braille, punycode, and more
8+ - ** Zero dependencies** - single binary, no plugins or external tools
9+ - ** JSON output** - structured data for scripting and automation
10+ - ** Multibase support** - self-describing encoded data with prefixes
11+ - ** Smart detection** - automatically identify unknown encodings
12+ - ** Error explanation** - detailed diagnostics for decode failures
13+ - ** Format normalization** - wrap, group, and clean encoded data
14+ - ** Batch operations** - encode/decode with all codecs at once
415
516## Install
617
@@ -11,29 +22,123 @@ cargo install --path .
1122## Quick Start
1223
1324``` bash
14- # Encode
25+ # Encode to base64
1526echo " Hello" | mbase enc --codec base64
1627# SGVsbG8K
1728
18- # Decode
29+ # Decode from base64
1930echo " SGVsbG8K" | mbase dec --codec base64
2031# Hello
2132
2233# Convert between encodings
2334echo " SGVsbG8K" | mbase conv --from base64 --to base58btc
2435# 2NEpo7TZRhna7vSvL
2536
37+ # Try text encodings
38+ echo " Hello" | mbase enc --codec rot13 # Uryyb
39+ echo " SOS" | mbase enc --codec morse # ... --- ...
40+ echo " test@example.com" | mbase enc --codec urlencoding # test%40example.com
41+
42+ # IPv6 compact representation (RFC1924)
43+ printf " ::1" | mbase enc --codec ipv6 # 00000000000000000001
44+ printf " 2001:db8::1" | mbase enc --codec ipv6 # 9R}vSQ9RqiCv7SR1r(Uz
45+
2646# List available codecs
2747mbase list
2848```
2949
50+ ## Examples
51+
52+ ```
53+ $ printf "mbase rokz" | mbase enc --all
54+ CODEC ENCODED
55+ ----------------------------------------------------------------------
56+ atbash nyzhv ilpa
57+ base2 01101101011000100110000101110011011001010010000...
58+ base8 155142141163145040162157153172
59+ base16lower 6d6261736520726f6b7a
60+ base16upper 6D6261736520726F6B7A
61+ base32lower nvrgc43febzg6232
62+ base32upper NVRGC43FEBZG6232
63+ base32padlower nvrgc43febzg6232
64+ base32padupper NVRGC43FEBZG6232
65+ base32hexlower dlh62sr541p6uqrq
66+ base32hexupper DLH62SR541P6UQRQ
67+ base32hexpadlower dlh62sr541p6uqrq
68+ base32hexpadupper DLH62SR541P6UQRQ
69+ zbase32 pitgnh5frb3g6454
70+ crockford32 DNH62WV541S6YTVT
71+ base32wordsafe pitgnh5frb3g6454
72+ base36lower 2c46lmitvvqlkvwa
73+ base36upper 2C46LMITVVQLKVWA
74+ base37 1KBS9ENGBK7NDL18
75+ base45 C$DHECDZC0LEJQD
76+ base58btc 79S9xSNYRQdHDs
77+ base58flickr 79r9XrnxqpChdS
78+ base58check hDNqPZfwaMymMTXPt2m
79+ base58ripple f9S9xS4YRQdHD1
80+ base62 2a6j5tU7aIGuBG
81+ base64 bWJhc2Ugcm9reg
82+ base64pad bWJhc2Ugcm9reg==
83+ base64url bWJhc2Ugcm9reg
84+ base64urlpad bWJhc2Ugcm9reg==
85+ base65536 ꉢ陳騠ꝯꁺ
86+ ascii85 D.6ppAKZ#3CO,
87+ z85 zdl{{wGV2iyKb
88+ base85chunked ZDL__Wgv2IYkB
89+ base85rfc1924 (encoding failed)
90+ base91 ;GH<f,|L3$P]B
91+ base92 #G9OG=jw{)9K0
92+ baudot 11100110010001100101000010010001010110000111110001
93+ bech32 data1d43xzum9ypex76m6qerv4p
94+ bech32m data1d43xzum9ypex76m649nqsr
95+ braille ⠍⠃⠁⠎⠑⠀⠗⠕⠅⠵
96+ bubblebabble xirekd-omelf-enodb-isokz-opulp-yx
97+ ipv6 (encoding failed)
98+ morse -- -... .- ... . / .-. --- -.- --..
99+ proquint kujof-kajug-kihob-lanoz-kotup
100+ punycode mbase rokz
101+ quoted-printable mbase=20rokz
102+ rot13 zonfr ebxm
103+ rot47 >32D6 C@<K
104+ a1z26 13-2-1-19-5-0-18-15-11-26
105+ rot18 zonfr ebxm
106+ unicode U+006D U+0062 U+0061 U+0073 U+0065 U+0020 U+007...
107+ tapcode 32 12 11 43 15 42 34 13 55
108+ uuencode *;6)A<V4@<F]K>@``
109+ urlencoding mbase%20rokz
110+ ```
111+
112+ ```
113+ $ printf "79r9XrnxqpChdS" | mbase dec --all
114+ CODEC DECODED (as text, or hex if binary)
115+ ----------------------------------------------------------------------
116+ atbash "79i9CimcjkXswH"
117+ base37 [5fe6f3de494aa3529d] (9 bytes)
118+ base58btc [6d82e124341a7c95fec9] (10 bytes)
119+ base58flickr "mbase rokz"
120+ base58ripple [01e309d4e7a776ec68ba6d] (11 bytes)
121+ base62 [012f3cfda3c72fd68fdcca] (11 bytes)
122+ z85 [161ef46754dd320a76dc81] (11 bytes)
123+ base85rfc1924 [1621d217a6b9369c26ed80] (11 bytes)
124+ base91 [ea55bb823dc9d8eb7ad7a0] (11 bytes)
125+ base92 [0252d44e7cee1e1f72e79f9d] (12 bytes)
126+ punycode "79r9xrnxqpchds"
127+ quoted-printable "79r9XrnxqpChdS"
128+ rot13 "79e9KeakdcPuqF"
129+ rot47 "fhCh)C?IBAr95$"
130+ rot18 "24e4KeakdcPuqF"
131+ urlencoding "79r9XrnxqpChdS"
132+ ```
133+
30134## Commands
31135
32136### ` enc ` - Encode bytes to text
33137``` bash
34138mbase enc --codec base64 --in data.bin --out encoded.txt
35139mbase enc --codec base32 --multibase # Add multibase prefix
36140mbase enc --all # Show all encodings
141+ mbase enc --codec base64 --json # JSON output
37142```
38143
39144### ` dec ` - Decode text to bytes
@@ -42,18 +147,21 @@ mbase dec --codec base64 --in encoded.txt --out data.bin
42147mbase dec --multibase # Auto-detect from prefix
43148mbase dec --all # Try all codecs
44149mbase dec --mode lenient # Ignore whitespace
150+ mbase dec --codec base64 --json # JSON output with hex
45151```
46152
47153### ` conv ` - Convert between encodings
48154``` bash
49155mbase conv --from base64 --to base32
50156mbase conv --from hex --to base58btc --in data.txt
157+ mbase conv --from base64 --to base32 --json # JSON output
51158```
52159
53160### ` verify ` - Check if input is valid
54161``` bash
55162mbase verify --codec base64 --in data.txt
56163mbase verify --codec hex --mode strict
164+ mbase verify --codec base64 --json # JSON output
57165```
58166
59167### ` fmt ` - Normalize/format encoded data
@@ -66,11 +174,13 @@ mbase fmt --codec hex --group 2 --sep : # AA:BB:CC:DD
66174``` bash
67175mbase detect --in unknown.txt
68176mbase detect --top 3 # Show top 3 candidates
177+ mbase detect --json # JSON output
69178```
70179
71180### ` explain ` - Debug decode failures
72181``` bash
73182mbase explain --codec base64 --in bad.txt
183+ mbase explain --codec base64 --json # JSON output
74184```
75185
76186### ` info ` - Show codec details
@@ -87,18 +197,123 @@ mbase list --json
87197
88198## Supported Codecs
89199
90- ** Base16:** hex, hexupper
91- ** Base32:** base32, base32upper, base32pad, base32padupper, base32hex, base32hexupper, base32hexpad, base32hexpadupper, zbase32, crockford32
92- ** Base36:** base36, base36upper
93- ** Base45:** base45
94- ** Base58:** base58btc, base58flickr, base58check
95- ** Base62:** base62
96- ** Base64:** base64, base64pad, base64url, base64urlpad
97- ** Base65536:** base65536
98- ** Base85:** ascii85, z85
99- ** Base91:** base91
100- ** Bech32:** bech32, bech32m
101- ** Other:** proquint, quotedprintable, uuencode
200+ ### Binary-to-Text Encodings
201+
202+ ** Base2:** ` base2 ` (binary)
203+ ** Base8:** ` base8 ` (octal)
204+ ** Base16:** ` base16lower ` (hex), ` base16upper ` (HEX)
205+ ** Base32:** ` base32lower ` , ` base32upper ` , ` base32padlower ` , ` base32padupper ` , ` base32hexlower ` , ` base32hexupper ` , ` base32hexpadlower ` , ` base32hexpadupper `
206+ ** Base32 Variants:** ` zbase32 ` , ` crockford32 ` (human-friendly), ` base32wordsafe ` (z-base-32, avoids similar chars)
207+ ** Base36:** ` base36lower ` , ` base36upper `
208+ ** Base37:** ` base37 ` (base36 + space character)
209+ ** Base45:** ` base45 ` (RFC 9285, QR-code friendly)
210+ ** Base58:** ` base58btc ` (Bitcoin), ` base58flickr ` , ` base58check ` (Bitcoin-style checksum), ` base58ripple ` (XRP)
211+ ** Base62:** ` base62 ` (0-9A-Za-z)
212+ ** Base64:** ` base64 ` , ` base64pad ` , ` base64url ` , ` base64urlpad `
213+ ** Base65536:** ` base65536 ` (Unicode, 2 bytes per char)
214+ ** Base85:** ` ascii85 ` (Adobe), ` z85 ` (ZeroMQ), ` base85chunked ` (4-byte chunks), ` base85rfc1924 ` (RFC1924 big-integer)
215+ ** Base91:** ` base91 ` (highest density printable ASCII)
216+ ** Base92:** ` base92 ` (92 printable ASCII characters)
217+
218+ ### Text Encodings & Ciphers
219+
220+ ** ROT Ciphers:** ` atbash ` (A↔Z), ` rot13 ` (letters +13), ` rot47 ` (ASCII !-~ ), ` rot18 ` (ROT13 + ROT5)
221+ ** Morse & Telegraph:** ` morse ` (international), ` baudot ` (ITA2 5-bit telegraph)
222+ ** Position Encodings:** ` a1z26 ` (A=1...Z=26), ` tapcode ` (Polybius square knock code)
223+ ** Symbolic:** ` braille ` (Unicode U+2800-U+28FF), ` unicode ` (U+XXXX code points)
224+ ** Pronounceable:** ` proquint ` (2 bytes per quint), ` bubblebabble ` (OpenSSH fingerprint style)
225+
226+ ### Internet & Standards
227+
228+ ** URL/Email:** ` urlencoding ` (RFC 3986 percent-encoding), ` quoted-printable ` (RFC 2045 MIME)
229+ ** Internationalization:** ` punycode ` (RFC3492 IDN encoding)
230+ ** Bitcoin/Crypto:** ` base58btc ` , ` base58check ` , ` bech32 ` (BIP-173), ` bech32m ` (BIP-350)
231+ ** Network:** ` ipv6 ` (RFC1924 compact IPv6 representation, 128-bit as base85)
232+ ** Legacy:** ` uuencode ` (Unix-to-Unix)
233+
234+ ## More Examples
235+
236+ ### IPv6 Address Encoding (RFC1924)
237+
238+ Compact 20-character base85 representation of IPv6 addresses:
239+
240+ ``` bash
241+ # Loopback address
242+ printf " ::1" | mbase enc --codec ipv6
243+ # 00000000000000000001
244+
245+ # Standard IPv6 address
246+ printf " 2001:db8::1" | mbase enc --codec ipv6
247+ # 9R}vSQ9RqiCv7SR1r(Uz
248+
249+ # RFC1924 example from spec
250+ printf " 1080:0:0:0:8:800:200C:417A" | mbase enc --codec ipv6
251+ # 4)+k&C#VzJ4br>0wv%Yp
252+
253+ # Decode back to canonical IPv6
254+ printf " 4)+k&C#VzJ4br>0wv%Yp" | mbase dec --codec ipv6
255+ # 1080::8:800:200c:417a
256+ ```
257+
258+ ### Letter Position & Tap Code
259+
260+ ``` bash
261+ # A1Z26: Letter position encoding
262+ echo " HELLO" | mbase enc --codec a1z26
263+ # 8-5-12-12-15
264+
265+ # Tap code (Polybius square knock code)
266+ echo " SOS" | mbase enc --codec tapcode
267+ # 43 34 43
268+ ```
269+
270+ ### Symbolic Encodings
271+
272+ ``` bash
273+ # Braille Unicode patterns
274+ printf " HELLO" | mbase enc --codec braille
275+ # ⠓⠑⠇⠇⠕
276+
277+ # Unicode code points
278+ printf " Hi🚀" | mbase enc --codec unicode
279+ # U+0048 U+0069 U+1F680
280+ ```
281+
282+ ### Pronounceable Encodings
283+
284+ ``` bash
285+ # Bubble Babble (OpenSSH fingerprint style)
286+ printf " test" | mbase enc --codec bubblebabble
287+ # xitakh-esalg-ox
288+
289+ # Proquint (pronounceable identifiers)
290+ printf " test" | mbase enc --codec proquint
291+ # lidoj-latuh
292+ ```
293+
294+ ### Telegraph & Historical
295+
296+ ``` bash
297+ # Baudot code (ITA2 5-bit telegraph)
298+ echo " HELLO" | mbase enc --codec baudot
299+ # 101000000110010100101100000010
300+
301+ # Morse code
302+ echo " HELLO" | mbase enc --codec morse
303+ # .... . .-.. .-.. ---
304+ ```
305+
306+ ### Internationalization
307+
308+ ``` bash
309+ # Punycode (IDN encoding for domain names)
310+ printf " münchen" | mbase enc --codec punycode
311+ # mnchen-3ya
312+
313+ # URL encoding
314+ echo " hello world!" | mbase enc --codec urlencoding
315+ # hello%20world%21
316+ ```
102317
103318## Use Cases
104319
@@ -112,6 +327,70 @@ mbase list --json
112327
113328** Scripting:** JSON output for programmatic processing of encode/decode operations.
114329
330+ ## JSON Output
331+
332+ Many commands support ` --json ` for structured output:
333+
334+ ``` bash
335+ # Encode with JSON
336+ $ echo " test" | mbase enc --codec base64 --json
337+ {
338+ " codec" : " base64" ,
339+ " input_length" : 5,
340+ " output" : " dGVzdAo=" ,
341+ " output_length" : 8,
342+ " multibase_prefix" : null
343+ }
344+
345+ # Decode with JSON (includes hex representation)
346+ $ echo " dGVzdA" | mbase dec --codec base64 --json
347+ {
348+ " codec" : " base64" ,
349+ " input" : " dGVzdA" ,
350+ " output_length" : 4,
351+ " output_hex" : " 74657374" ,
352+ " output_text" : " test" ,
353+ " multibase_prefix" : null
354+ }
355+
356+ # Convert with JSON
357+ $ echo " dGVzdA" | mbase conv --from base64 --to base32 --json
358+ {
359+ " from_codec" : " base64" ,
360+ " to_codec" : " base32" ,
361+ " input" : " dGVzdA" ,
362+ " output" : " orsxg5a"
363+ }
364+
365+ # Detect with JSON
366+ $ echo " SGVsbG8" | mbase detect --json
367+ {
368+ " schema_version" : 1,
369+ " candidates" : [
370+ {
371+ " codec" : " base64" ,
372+ " confidence" : 0.75,
373+ " reasons" : [" all characters valid" , " decodes successfully" ],
374+ " warnings" : []
375+ }
376+ ],
377+ " input_preview" : " SGVsbG8"
378+ }
379+
380+ # List all codecs as JSON
381+ $ mbase list --json
382+ [
383+ {
384+ " name" : " base64" ,
385+ " aliases" : [" b64" ],
386+ " multibase_code" : " m" ,
387+ " description" : " Standard base64 encoding"
388+ }
389+ ]
390+ ```
391+
392+ Commands supporting ` --json ` : ` enc ` , ` dec ` , ` conv ` , ` list ` , ` info ` , ` verify ` , ` detect ` , ` explain `
393+
115394## Files & I/O
116395
117396- ` --in ` defaults to stdin (` - ` )
0 commit comments