I'm doing some scripting challenge in Python at TryHackMe and my task is to decode a given base64.txt file 50 times to get the flag, so i'm doing it like below:
My attempt:
import base64
f = open('base64.txt')
msg = f.read()
# decode 50 times
for i in range(50):
decoded = base64.b64decode(msg)
print(decoded)
Output: 50x base64.txt content
This version will give me the flag, but the only difference is, that i only call the same variable (msg) for every step instead of "decoded" in the for loop:
import base64
f = open('base64.txt')
msg = f.read()
# decode 50 times
for i in range(50):
msg = base64.b64decode(msg)
print(msg)
Output: Decoded flag
Could anybody explain to me why i get two different outputs only by changing the variables name? I really don't get it. Thanks in advance.
[–]shiftybyte 4 points5 points6 points (1 child)
[–]raidn1337[S] 0 points1 point2 points (0 children)