Rot Algorithm in Python
1 min read

Rot Algorithm in Python

Rot Algorithm in Python

A while ago I wanted to send a bunch of emails to building companies in order to get some quotes and/or information. Unfortunately, the website in question ( doesn't provide emails in clear text to allow me copy/paste. Instead it uses a Rotating cypher algorithm (I guess it must be simple enough to be able to be decrypted by a browser).

After a couple of emails, where the process of sending through the website costed me some time I figured that it would be easier to see and implement the algorithm myself. The result is a pretty simple hack, in python:

def decrypt(encoded):
    ref = ord('r')
    clear = ord('e')

    a_ord = ord('a')

    outb = ""

    for c in encoded:
        oc = ord(c)

        # Only decrypt the alpha.
        if oc in range(ord('a'), ord('z') + 1):
            rc = chr((ord(c) - a_ord + clear - ref) % 26 + a_ord)
            rc = c
        outb += rc
    return outb

Calling it with znvygb:[email protected], you'll get mailto:[email protected]. Excellent for my purpose.