python2.7 encode2.py

 avatar
unknown
plain_text
2 years ago
1.7 kB
7
Indexable
import string
from base64 import b64encode, b64decode

secret = 'dbxxfortune'

secret_encoding = ['step1', 'step2', 'step3']

def step1(s):
    # we need to reverse the process when this is called, so we have flipped our values
    _step1 = string.maketrans("zyxwvutsrqponZYXWVUTSRQPONmlkjihgfedcbaMLKJIHGFEDCBA","mlkjihgfedcbaMLKJIHGFEDCBAzyxwvutsrqponZYXWVUTSRQPON")
    return string.translate(s, _step1)

def step2(s): return secret + " is " + s

# heres the tricky part we need to reverse our shifts
def step3(plaintext, shift=4):
    loweralpha = string.ascii_lowercase
    shifted_string = loweralpha[shift:] + loweralpha[:shift]
    converted = string.maketrans(loweralpha,shifted_string)
    return string.translate(plaintext,converted)

def make_secret(plain):
    # start as base64
    x = b64encode(plain)
    a = '{}'.format(x)
    # step 1
    r = "step1"
    si = secret_encoding.index(r) + 1
    _a = globals()[r](a)
    a = '{}'.format(_a)
    # step 3
    r = "step3"
    si = secret_encoding.index(r) + 1
    _a = globals()[r](a)
    a = '{}'.format(_a)
    # step 3
    r = "step3"
    si = secret_encoding.index(r) + 1
    _a = globals()[r](a)
    a = '{}'.format(_a)
    # step 1
    r = "step1"
    si = secret_encoding.index(r) + 1
    _a = globals()[r](a)
    a = '{}'.format(_a)
    # step 3
    r = "step3"
    si = secret_encoding.index(r) + 1
    _a = globals()[r](a)
    a = '{}'.format(_a)
   # step 2
    r = "step2"
    si = secret_encoding.index(r) + 1
    _a = globals()[r](a)
    a = '{}'.format(_a)
    # step final
    return a

if __name__ == '__main__':
    print(make_secret(secret))
Editor is loading...
Leave a Comment