defencrypt(msg, perm): W = len(perm) while len(msg) % (2*W): msg += "." msg = msg[1:] + msg[:1] msg = msg[0::2] + msg[1::2] msg = msg[1:] + msg[:1] res = "" for j in xrange(0, len(msg), W): for k in xrange(W): res += msg[j:j+W][perm[k]] msg = res return msg
defencord(msg, perm, l): for _ in xrange(l): msg = encrypt(msg, perm) return msg
W, l = 7, random.randint(0, 1337) perm = range(W) random.shuffle(perm)
import itertools import random import time import sys
defdecrypt(cipher,perm): msg = "" msg2 = "" for j in xrange(0,70,7): for k in xrange(7): msg += cipher[j:j+7][perm.index(k)] #print msg + "$$$$$$$$$$$$$" #print len(msg) msg = msg[-1:] + msg[:-1] for m in xrange(35): msg2 += msg[m::35] msg3 = msg2[-1:] + msg2[:-1] #plaintext = msg[:-2] #print len(msg) return msg3
defbrute(): perm0 = range(7) list1 = [] iter = itertools.permutations(perm0,7) list1.append(list(iter)) for i in xrange(len(list1[0])): cipher = "11d.3ilVk_d3CpIO_4nlS.ncnz3e_0S}M_kn5scpm345n3nSe_u_S{iy__4EYLP_aAAall" #print n perm = list(list1[0][i]) print perm for m in xrange(1338): #print cipher #print m cipher = decrypt(cipher,perm) print cipher if cipher.startswith('ASIS{') and cipher.endswith('}..'): print cipher print m print perm sys.exit(0) print"Nothing Found" print"All down."