picoctf/rev/transformation/solve.py

19 lines
446 B
Python
Raw Permalink Normal View History

2024-09-01 23:15:27 +02:00
#!/usr/bin/env nix-shell
#!nix-shell -i python3 -p python3
# enc = ''.join([chr((ord(flag[i]) << 8) + ord(flag[i + 1])) for i in range(0, len(flag), 2)])
def decrypt(enc):
result = []
for x in enc:
n = ord(x)
result.append(chr((n & 0xFF00) >> 8))
result.append(chr(n & 0xFF))
return "".join(result)
if __name__ == "__main__":
with open('enc') as file:
enc = file.read()
print(decrypt(enc))