init
This commit is contained in:
commit
ec14efb417
7 files changed
+182
No files matched your search
@@ -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)
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user