ROT47: ROT13 for ASCII Printable Characters
Learn about ROT47, an extended version of ROT13 that rotates all 94 printable ASCII characters including digits and symbols, not just letters.
Detailed Explanation
ROT47: Beyond Letters
ROT47 extends the ROT13 concept to cover all 94 printable ASCII characters (code points 33 through 126). Instead of rotating within a 26-letter alphabet, it rotates within the 94-character set of printable ASCII.
How ROT47 Works
The printable ASCII characters span from ! (33) to ~ (126), giving us 94 characters. ROT47 shifts each by 47 positions:
ROT47('A') → 'p' (65 + 47 = 112)
ROT47('1') → '`' (49 + 47 = 96)
ROT47('!') → 'P' (33 + 47 = 80)
Self-Reciprocal Like ROT13
Since 47 is exactly half of 94, ROT47 is self-reciprocal:
ROT47(ROT47(x)) = x
This mirrors ROT13's relationship with the 26-letter alphabet.
Comparison with ROT13
| Feature | ROT13 | ROT47 |
|---|---|---|
| Character set | A–Z, a–z (52 chars) | ! through ~ (94 chars) |
| Rotation amount | 13 | 47 |
| Affects digits | No | Yes |
| Affects symbols | No | Yes |
| Preserves spaces | Yes | Yes (space is below ASCII 33) |
| Self-reciprocal | Yes | Yes |
Implementation
function rot47(text) {
return text.replace(/[!-~]/g, c => {
const code = c.charCodeAt(0);
return String.fromCharCode(33 + ((code - 33 + 47) % 94));
});
}
When to Use ROT47
ROT47 is useful when you want to obfuscate digits and symbols in addition to letters:
- Email addresses:
user@example.com→FD6Co6I2>A=6]4@> - URLs: digits and special characters are also scrambled
- API keys: all characters are affected
Limitations
Like ROT13, ROT47 provides zero security. It is pure obfuscation and should never be used to protect sensitive data.
Use Case
ROT47 is useful when you need to obfuscate text that contains digits, email addresses, URLs, or other non-alphabetic content. It appears in CTF challenges, source code obfuscation, and situations where ROT13 alone would leave too much of the original content readable.