ASCII Bit Shuffler
Encode and decode ASCII text by shuffling bit positions within each byte using a configurable permutation vector. Visual binary mapping included.
About
Every ASCII character occupies 8 bits. Rearranging those bits according to a fixed permutation vector P produces a different byte value - visually garbled text that is trivially reversible if P is known, but opaque otherwise. This is not encryption; it provides zero cryptographic security. It is, however, a useful primitive for obfuscation layers, CTF challenges, steganographic carriers, and educational demonstrations of bijective mappings at the bit level. A malformed permutation (duplicate indices, out-of-range values) silently destroys data because the mapping is no longer bijective. This tool validates the permutation before processing and computes the inverse automatically, eliminating that class of error.
The tool operates entirely in-browser on code points 0 - 127 (strict 7-bit ASCII). Characters outside this range are rejected with positional feedback. Pro tip: if you chain two different permutation vectors, the composite is itself a permutation - compute it by applying P2 after P1 to the identity vector.
Formulas
Given an input byte B with bits b0b1β¦b7 (MSB-first, where b0 is bit 7) and a permutation vector P of length 8, the shuffled byte Bβ² is computed as:
where bit(B, k) extracts the k-th bit (counting from MSB = 0). The inverse permutation Pβ1 satisfies:
where P[i] = source bit index that maps to output position i, Bβ² = shuffled output byte, bit(B, k) = value of bit at position k in byte B (0 or 1). A valid permutation must be a bijection on the set {0, 1, β¦, 7}: every index appears exactly once. The number of distinct permutations is 8! = 40320.
Reference Data
| Permutation Name | Vector P[0β¦7] | Description | Inverse Vector |
|---|---|---|---|
| Identity | 0 1 2 3 4 5 6 7 | No change; output equals input | 0 1 2 3 4 5 6 7 |
| Reverse | 7 6 5 4 3 2 1 0 | Mirror all bit positions | 7 6 5 4 3 2 1 0 |
| Rotate Left 1 | 1 2 3 4 5 6 7 0 | Circular left shift by 1 | 7 0 1 2 3 4 5 6 |
| Rotate Left 2 | 2 3 4 5 6 7 0 1 | Circular left shift by 2 | 6 7 0 1 2 3 4 5 |
| Rotate Left 3 | 3 4 5 6 7 0 1 2 | Circular left shift by 3 | 5 6 7 0 1 2 3 4 |
| Swap Nibbles | 4 5 6 7 0 1 2 3 | Exchange upper and lower 4 bits | 4 5 6 7 0 1 2 3 |
| Interleave | 0 2 4 6 1 3 5 7 | Even indices first, then odd | 0 4 1 5 2 6 3 7 |
| De-interleave | 0 4 1 5 2 6 3 7 | Inverse of Interleave | 0 2 4 6 1 3 5 7 |
| Butterfly | 7 0 6 1 5 2 4 3 | Alternating outside-in mapping | 1 3 5 7 6 4 2 0 |
| Odd-Even Swap | 1 0 3 2 5 4 7 6 | Swap adjacent bit pairs | 1 0 3 2 5 4 7 6 |
| DES IP Subset | 5 0 3 6 1 4 7 2 | Inspired by DES initial permutation (scaled to 8 bits) | 1 4 7 2 5 0 3 6 |
| Fibonacci Scatter | 0 1 1 2 3 5 0 2 | INVALID - duplicate indices; tool rejects this | - |
| High-Low Split | 4 5 6 7 3 2 1 0 | Upper nibble first, lower reversed | 7 6 5 4 0 1 2 3 |
| Bit Cascade | 6 4 2 0 7 5 3 1 | Even positions descending, odd descending | 3 7 2 6 1 5 0 4 |
| AES ShiftRow-ish | 0 3 6 1 4 7 2 5 | Row-shift pattern scaled to 8 bits | 0 3 6 1 4 7 2 5 |