ASCII Bit Flipper
Visualize and flip individual bits of ASCII characters interactively. See binary representations, toggle bits, and observe how single-bit changes alter text.
About
A single bit flip in memory can corrupt a byte, change a character, or crash a system. This tool renders each character of your input as an 8-bit binary word and lets you toggle any bit position from b7 (MSB, weight 128) down to b0 (LSB, weight 1). The flipped codepoint is computed via XOR: c′ = c ⊕ 2k, where k is the toggled bit index. Flipping bit 5 of an uppercase ASCII letter converts it to lowercase and vice versa - a property exploited in case-insensitive comparison optimizations. Flipping bit 6 of a digit character produces a control code, which can break parsers and protocols that assume clean input.
This tool operates strictly within the 7-bit ASCII range (0 - 127). Flipped values exceeding this range are displayed with their codepoint but may not render as printable glyphs. The tool approximates real hardware bit errors; actual memory corruption involves ECC detection, Hamming distance analysis, and parity checks not modeled here. Use it to study encoding vulnerabilities, understand XOR masking, or demonstrate why single-bit errors matter in serial protocols like UART where no parity bit is configured.
Formulas
Each ASCII character is represented by a 7-bit codepoint stored in an 8-bit byte. The decimal value of a byte is the weighted sum of its bits:
where bi ∈ {0, 1} is the value of the i-th bit.
Flipping bit k is performed using a bitwise XOR with a mask containing a single set bit at position k:
where c is the original codepoint, c′ is the flipped codepoint, ⊕ denotes bitwise XOR, and k is the zero-indexed bit position (0 = LSB, 7 = MSB).
The Hamming distance between original and flipped strings equals the total number of toggled bits:
where popcount counts the number of set bits in the XOR result, and n is the string length. For ASCII case conversion, the relationship exploits the fact that uppercase letters (65 - 90) and lowercase letters (97 - 122) differ only in bit 5 (weight 32): clower = cupper ⊕ 32.
Reference Data
| Char | Dec | Hex | Binary | Category | Bit 5 Flip | Bit 6 Flip |
|---|---|---|---|---|---|---|
| A | 65 | 0x41 | 01000001 | Uppercase | a (97) | ! (33) |
| a | 97 | 0x61 | 01100001 | Lowercase | A (65) | ! (33) |
| 0 | 48 | 0x30 | 00110000 | Digit | P (80) | p (112) |
| 9 | 57 | 0x39 | 00111001 | Digit | Y (89) | y (121) |
| Z | 90 | 0x5A | 01011010 | Uppercase | z (122) | : (58) |
| z | 122 | 0x7A | 01111010 | Lowercase | Z (90) | : (58) |
| &space& | 32 | 0x20 | 00100000 | Whitespace | @ (64) | NUL (0) |
| ! | 33 | 0x21 | 00100001 | Punctuation | A (65) | SOH (1) |
| @ | 64 | 0x40 | 01000000 | Symbol | ` (96) | NUL (0) |
| ~ | 126 | 0x7E | 01111110 | Symbol | ^ (94) | > (62) |
| / | 47 | 0x2F | 00101111 | Symbol | O (79) | o (111) |
| \n | 10 | 0x0A | 00001010 | Control | * (42) | J (74) |
| \r | 13 | 0x0D | 00001101 | Control | - (45) | M (77) |
| \t | 9 | 0x09 | 00001001 | Control | ) (41) | I (73) |
| DEL | 127 | 0x7F | 01111111 | Control | ? (63) | > (62) |
| NUL | 0 | 0x00 | 00000000 | Control | &space& (32) | @ (64) |