picoctf/rev/transformation/solve.py

19 lines
446 B
Python
Executable File

#!/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))