⊕ 2016-07-06

Often times it's fun to play with toy crypto puzzles, so for a quick one today I decided to do a quick writeup on my modern take on the ceaser cipher. Taking unicode (UTF-8 specifically) and flip the first bit. This is the same as rotating the alphabet by 0x8000 instead of 13. If you have run into this in any security capture the flag in the last few years than you know who was responsible and who to send hate mail to. It shows the same principles as a normal ROT-13 except for in a modern binary driven world that has a lot of encoding types! In fact it's simple to apply this to any bit fixed encoding such as UTF-16,UTF-32, etc.

For example the string: ROTx8000 has the interesting side effect of turning all your english letters into chinese characters!‽?! turns into this monstrosity (hope you have a good browser font):


Taking that same string again and it reverses it back to the original string. This is 100% useless, but I thought it was entertaining. Here is the example code:

 1#!/bin/env python
 2import sys
 4#Rotate by 0x8000 (UTF-8 rot)
 5def rotx8(s):
 6    y = ''
 7    for x in s:
 8            y += chr(ord(x) ^ 0x8000)
 9    return y
12    print(rotx8(sys.argv[1]))
14    print("Cannot rot UTF-8 (rot0x8000 / rot32768) string")

Use it like so: $ python ./ 'text to encode'