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

+28
View File
@@ -0,0 +1,28 @@
import hmac
import hashlib
import secrets
# Generate and write shared key
shared_secret: bytes = secrets.token_bytes(16)
with open('k', 'wb') as file:
file.write(shared_secret)
# Take in message and compute hmac
m = input("Message: ").encode()
hmac_object: hmac.HMAC = hmac.new(shared_secret, m, hashlib.sha256)
m_hash = hmac_object.digest()
print(f'HMAC: {m_hash}')
# Write hmac digest and message
with open('mactext', 'wb') as file:
file.write(m + m_hash)