Untitled

mail@pastecode.io avatar
unknown
python
a year ago
1.9 kB
10
Indexable
Never
import random

class TurmoilCipher:
    def __init__(self, plain):
        self.plain_to_turmoil = plain
    
    def __confusion(self, data):
        return self.__c0nfusion(''.join([ str(ord(l.lower()))+'187' for l in data]))

    def __c0nfusion(self, data):
        return self.__c0nfus1on(str(bin(int(data))[2:]))

    def __c0nfus1on(self, data):
        turmoil_cipher = ''
        for value in data:
            rconfz_1 = random.randint(6,9)
            rconfz_2 = random.randint(2,5)
            confusion = {rconfz_1:0,rconfz_2:1}
            rev_confusion = {value: key for key, value in confusion.items()}
            turmoil_cipher+=str(rev_confusion.get(int(value)))
        return turmoil_cipher

    def turmoilify(self):
        turmoilified_msg = self.__confusion(self.plain_to_turmoil)
        return turmoilified_msg


if(__name__=="__main__"):
	cipher = TurmoilCipher(input('Turmoilify a msg: '))
	print(cipher.turmoilify())


# Cryptography chall by Haxinja
# The code above is the algorithm used to encrypt the flag
# Task: Decipher the flag
# Ciphered flag: 4973288397453233433838227764797742743483562974765456745424585675698249838993563554522984762747287942459538734465279625599929639764553257688347376329683376629532382884439998852256696295794893869375399688897567234867682558394644883446363649846395682245495287433688484742766326467524397922432945998868963784622759245265693573273386739345239923645849356484596932727742838893543838648885685346349583992944398847649869827635587338466886834287968956926447545762588945557743577428659763462345387664352456253343679473398885999838554857748248223273875495352428272872929487676257877886722258468635292878753578856538283435857322468329572757859438475844573652598724366779233876432428745746586622753438875557847665263229362932685766646586474774455624277848876839767728676365425669487433268574756228694322399925434255669934