DarkCTF 2020: Cryptography/WEIRD ENCRYPTION

Cryptography/WEIRD ENCRYPTION

377 points

I made this weird encryption I hope you can crack it.
File

enc.py

prefix="Hello. Your flag is DarkCTF{"
suffix="}."
main_string="c an u br ea k th is we ir d en cr yp ti on".split()

clear_text = prefix + flag + suffix
enc_text = ""
for letter in clear_text:
    c1 = ord(letter) / 16
    c2 = ord(letter) % 16
    enc_text += main_string[c1]
    enc_text += main_string[c2]

print enc_text

Encrypted

eawethkthcrthcrthonutiuckirthoniskisuucthththcrthanthisucthirisbruceaeathanisutheneabrkeaeathisenbrctheneacisirkonbristhwebranbrkkonbrisbranthypbrbrkonkirbrciskkoneatibrbrbrbrtheakonbrisbrckoneauisubrbreacthenkoneaypbrbrisyputi

Solution

main_string = "c an u br ea k th is we ir d en cr yp ti on".split()
flag = open('Encrypted', 'r').read()

def decrypt(letter):
    return main_string.index(letter[0]) * 16 + main_string.index(letter[1])


part = ''
letter = []
decrypted = ''
for j, i in enumerate(flag):
    part += i
    if part in main_string and not (part == 'c' and flag[j+1] == 'r'):
        letter.append(part)
        part = ''
    if len(letter) == 2:
        decrypted += chr(decrypt(letter))
        letter = []

print(decrypted)

weirdencryption1

DarkCTF{0k@y7h1571m3Y0uN33d70Br3@k_M3}

Privacy Policy
luc © 2021