Flink.Thomas Flink.Thomas - 2 months ago 12
Python Question

running python def and cipher text

So I have this function which is suppose to de-crypt a cipher text but I do not know how to run this function, I barely use python any help would be must appreciated.

def decrypt1(ctext, key):
if key % 4 == 0:
perm = [4, 1, 3, 6, 7, 5, 2, 0]
elif key % 4 == 1:
perm = [2, 4, 0, 5, 7, 6, 3, 1]
elif key % 4 == 2:
perm = [1, 7, 0, 2, 6, 5, 3, 4]
perm = [5, 4, 1, 7, 0, 2, 3, 6]
rev_perm = [perm.index(i) for i in range(len(perm))]
ptext = ""
for j in range(0, len(ctext), 8):
block = ctext[j: j+8]
ptext += ''.join(block[p] for p in rev_perm)
return ptext

Here is the ciphertext

ehn Aotrf irtmeot m enoiaoig sl sgnn iinis prga hmwen rinta fs sse
eelo v aesnothmte phssoot oa ftof erg i-terasea lghta s ep-oifotraht
n tt w aacomt eeks;h e enthsp saisa,eaasbl ihd n tsehssi t grapins
gliiintoFe m. rray m ptn tIdoosip raeoft i, raeytm hr sdo oenek itli
cu. t Shli nasais agisn,dcathe uodwn y ahldil rovydl aihcme isite.if
Y ie nthrargcinon n oemed neh vetofs i, rhtemwal l afensip oetootr
lrmoatu;is b f atiset f rulomainde o e agthwB etvs.udiIy b nouio
cslae dr l ehhtesti n igsnh oayure st r aID a sy.oupo nt toylral usdgi
oo ll wnhaosps hi; eehlavtae eegrttr brpa ,dhaein tudtn p seeeh lstr
orpa ra ;nbodi f ortb sdi aanibs usem estoeht dtwi ets iasr
gmhaontev ewasehfso t saaie, b dtisaoyi f uotu pt o tr geaao o
ladnw ogyuranao gn d krhbeatel eax,oynrad usdga oo opelr sibOdee.
sudv re erue:masep ao ndroio prtnses i btllnti a .si hng



ctext = "your ciphertext"
result = decrypt1(ctext, key)

Please make your ciphertext as your first argument, and the key as your second argument to your function decrypt1 according to your actual situation.