Algoric-Shift
Category: Cryptography
50 points
ciphered text : HESL{LRAT5PN51010T_CNPH1R}3
Try decrypting:
file: script.py
script.py
text = 'flag{...}'
key = [3,1,2]
li0 = []
li1 = []
li2 = []
for i in range(0,len(text)):
if i % 3 == 0:
li0.append(text[i])
elif (i - 1) % 3 == 0:
li1.append(text[i])
elif (i - 2) % 3 == 0:
li2.append(text[i])
li = []
for i in range(len(li1)):
li.append(li1[i])
li.append(li2[i])
li.append(li0[i])
# print(li)
print("The ciphered text is :")
ciphered_txt = (''.join(li))
print(ciphered_txt)
Solution
I’ve changed given Python script as below to reverse flag encryption.
text = 'HESL{LRAT5PN51010T_CNPH1R}3'
key = [3,1,2]
li0 = []
li1 = []
li2 = []
for i in range(0,len(text)):
if i % 3 == 0:
li2.append(text[i])
elif (i - 1) % 3 == 0:
li0.append(text[i])
elif (i - 2) % 3 == 0:
li1.append(text[i])
li = []
for i in range(len(li1)):
li.append(li1[i])
li.append(li2[i])
li.append(li0[i])
print("The ciphered text is :")
ciphered_txt = (''.join(li))
print(ciphered_txt)
Output:
SHELL{TRAN5P051T10N_C1PH3R}
Flag
SHELL{TRAN5P051T10N_C1PH3R}