This commit is contained in:
JISAUAY committed 2025-10-27 14:32:30 -05:00
commit ec14efb417
7 files changed
+182

No files matched your search

+29
View File
@@ -0,0 +1,29 @@
import hmac
import hashlib
# Import shared secret
with open('k', 'rb') as file:
shared_key = file.read()
# Compute hmac
with open('mactext', 'rb') as file:
data = file.read()
m = data[:18]
m_hash = data[18:]
hmac_oject: hmac.HMAC = hmac.new(shared_key, m, hashlib.sha256)
derived_hmac = hmac_oject.digest()
print(f'Derived HMAC: {hmac_oject.digest()}')
if derived_hmac == m_hash:
print("HMAC matches message")
else:
print("HMAC does not match message")