Ciphers
ROT-47
Shift 47 over the 94 printable ASCII characters, digits and punctuation included. Self-inverse.
- create
- create("rot47")
- family
- Shift
- options
- none
- self-inverse
- yes
- keyspace
- 1 (fixed shift=47)
- try it
- ciphers rot47 "Hello, World! 123"
ROT-47 works on printable ASCII 33 to 126, so digits and punctuation change too. 47 is half of 94, so it's its own inverse. Space, tab and newline sit outside the range and pass through.
const rot47 = create("rot47");
rot47.encode("Test 123!").text; // "%6DE `abP"
rot47.decode("%6DE `abP").text; // "Test 123!"
rot47.encode("A\tB\nC").text; // "p\tq\nr"
preserveCase means nothing here, upper and lower case are just different characters in the range. And stripNonAlpha would defeat the point.