ALL the CTFS of Crypto2025 finally
This commit is contained in:
27
crypto-hash/equality/chall.py
Normal file
27
crypto-hash/equality/chall.py
Normal file
@ -0,0 +1,27 @@
|
||||
from Crypto.Hash import MD4
|
||||
import hashlib
|
||||
from binascii import unhexlify
|
||||
from secret import flag
|
||||
|
||||
|
||||
def md4(data: bytes) -> str:
|
||||
h = MD4.new()
|
||||
h.update(data)
|
||||
return h.hexdigest()
|
||||
|
||||
|
||||
print("Find two strings that are both equal and different! I'll use _optimized algorithms_ to check.")
|
||||
|
||||
s1 = unhexlify(input("Enter the first string: "))
|
||||
s2 = unhexlify(input("Enter your second string: "))
|
||||
|
||||
md4_s1 = md4(s1)
|
||||
md4_s2 = md4(s2)
|
||||
|
||||
md5_s1 = hashlib.md5(s1).hexdigest()
|
||||
md5_s2 = hashlib.md5(s2).hexdigest()
|
||||
|
||||
if md4_s1 == md4_s2 and md5_s1 != md5_s2:
|
||||
print(f"Good job! {flag}")
|
||||
else:
|
||||
print("Try again!")
|
||||
Reference in New Issue
Block a user