> For the complete documentation index, see [llms.txt](https://cajac.gitbook.io/ctf-notes/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://cajac.gitbook.io/ctf-notes/encoding-and-decoding/rotations/rot47.md).

# Rot47

ROT47 is a derivative of ROT13 which, in addition to scrambling the basic letters, treats numbers and common symbols. Instead of using the sequence A–Z as the alphabet, ROT47 uses a larger set of characters from the common [character encoding](https://en.wikipedia.org/wiki/Character_encoding) known as [ASCII](https://en.wikipedia.org/wiki/ASCII). Specifically, the 7-bit printable characters, excluding space, from decimal 33 '!' through 126 '\~', 94 in total, taken in the order of the numerical values of their ASCII codes, are rotated by 47 positions, without special consideration of case. For example, the character A is mapped to p, while a is mapped to 2. The use of a larger alphabet produces a more thorough obfuscation than that of ROT13; for example, a telephone number such as +1-415-839-6885 is not obvious at first sight from the scrambled result Z'\c\`d\gbh\eggd. On the other hand, because ROT47 introduces numbers and symbols into the mix without discrimination, it is more immediately obvious that the text has been encoded.

Example:

The Quick Brown Fox Jumps Over The Lazy Dog.

enciphers to

%96 "F:4< qC\@H? u\@I yF>AD \~G6C %96 {2KJ s\@8]

## Convert in bash

### tr command

You can use the `tr` command to do `ROT47`

```bash
┌──(kali㉿kali)-[~]
└─$ echo '*@F DA:? >6 C:89E C@F?5 323J C:89E C@F?5 Wcf E:>6DX' | tr '\!-~' 'P-~\!-O'     
You spin me right round baby right round (47 times)
```

## Convert with online services

You can also convert `ROT47` with one of these online services:

CyberChef: <https://gchq.github.io/CyberChef/#recipe=ROT47(47)>

dcode.fr: <https://www.dcode.fr/rot-47-cipher>

## Resources

ROT13 - Wikipedia: <https://en.wikipedia.org/wiki/ROT13#Variants>
