ALL the CTFS of Crypto2025 finally

This commit is contained in:
emln
2025-06-02 19:35:30 +02:00
parent aa0fe54b3b
commit 50c18f35b9
442 changed files with 1743 additions and 8 deletions

View File

@ -0,0 +1,31 @@
import os
import random
from time import time
from Crypto.Cipher import ChaCha20
from Crypto.Util.number import long_to_bytes
from secret import flag
key = os.urandom(32)
def encrypt(msg):
random.seed(int(time()))
cipher = ChaCha20.new(
key=key, nonce=long_to_bytes(random.getrandbits(12*8)))
return cipher.encrypt(msg.encode())
def main():
confirm = input("Want to encrypt? (y/n/f)")
while confirm.lower() != 'n':
if confirm.lower() == 'y':
msg = input("> ")
print(encrypt(msg).hex())
elif confirm.lower() == 'f':
print(encrypt(flag).hex())
confirm = input("Want to encrypt something else? (y/n/f)")
if __name__ == '__main__':
main()