Files
crypto2025/crypto-simmetric/long-secret-message/chall-original.py
2025-06-02 19:35:30 +02:00

20 lines
464 B
Python

import os
from Cryptodome.Cipher import ChaCha20
key = os.urandom(32)
nonce = os.urandom(12)
print(f"Using key: {key.hex()}, nonce: {nonce.hex()}")
with open("./hacker-manifesto.txt") as f:
lines = f.readlines()
#
#hacker-manifesto.txt encrypted in enc
enc = []
for line in lines:
cipher = ChaCha20.new(key=key, nonce=nonce)
enc.append(cipher.encrypt(line.encode()).hex())
with open("./hacker-manifesto.enc", "w") as f:
f.write("\n".join(enc))