Cipher's Secret Message
Sharpen your cryptography skills by analyzing code to get the flag.
Introduction
Let’s read the content  As you can see, we have to decrypt that to retrieve the flag
 As you can see, we have to decrypt that to retrieve the flag
 We can see the whole code here, we have to modifiy the code to get the flag
 We can see the whole code here, we have to modifiy the code to get the flag
1
2
3
4
5
6
7
8
9
10
11
from secret import FLAG
def enc(plaintext):
    return "".join(
        chr((ord(c) - (base := ord('A') if c.isupper() else ord('a')) + i) % 26 + base) 
        if c.isalpha() else c
        for i, c in enumerate(plaintext)
    )
with open("message.txt", "w") as f:
    f.write(enc(FLAG))
- enc() applies a Caesar cipher with incremental shift (+i)
- . + i adds the character’s index, creating a progressive shift per character
- chr(…) converts the resulting number back into a ciphered character.
Once we know what does the code do. we can procede to modify it  As you can see I just edit the variable and the hypertext to ciphertext. but when I tried to execute it, there is an error,
 As you can see I just edit the variable and the hypertext to ciphertext. but when I tried to execute it, there is an error,
But the problem here is cause, I just forgot to put the variable decrypt next to def, we can modify it just adding decrypt
1
2
3
4
5
6
7
8
9
10
message = "a_up4qr_kaiaf0_bujktaz_qm_su4ux_cpbq_ETZ_rhrudm"
def decrypt(cyphertext):
    return "".join(
        chr((ord(c) - (base := ord('A') if c.isupper() else ord('a')) + i) % 26 + base) 
        if c.isalpha() else c
        for i, c in enumerate(cyphertext)
    )
print("THM{" + decrypt(message) + "}")
I added the
messagevariable manually with theencryptedstring provided in the challenge.
I created a new function called decrypt() (instead of enc()) and changed the logic:
I replaced + i with - i to reverse the Caesar incremental shift.
This essentially undoes the encryption applied originally in enc().
Finally, I used print("THM{" + decrypt(message) + "}") to wrap the output in the expected flag format.
YOU HAVE TO KNOW THAT IS THERE IS A GRAMATICAL ERROR IS CAUSE IM LEARNING ENGLISH, THANK YOU



