29 lines
801 B
Python
29 lines
801 B
Python
from Crypto.Cipher import ChaCha20
|
|
from secret import FLAG
|
|
import os
|
|
|
|
|
|
def encryptMessage(message, key, nonce):
|
|
cipher = ChaCha20.new(key=key, nonce=iv)
|
|
ciphertext = cipher.encrypt(message)
|
|
return ciphertext
|
|
|
|
|
|
def writeData(data):
|
|
with open("out.txt", "w") as f:
|
|
f.write(data)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
message = b"Our counter agencies have intercepted your messages and a lot "
|
|
message += b"of your agent's identities have been exposed. In a matter of "
|
|
message += b"days all of them will be captured"
|
|
|
|
key, iv = os.urandom(32), os.urandom(12)
|
|
|
|
encrypted_message = encryptMessage(message, key, iv)
|
|
encrypted_flag = encryptMessage(FLAG, key, iv)
|
|
|
|
data = iv.hex() + "\n" + encrypted_message.hex() + "\n" + encrypted_flag.hex()
|
|
writeData(data)
|