Introduction
Imagine sending an important letter and wanting the receiver to be sure it really came from you and wasn't changed on the way. Digital signatures solve this problem for electronic messages and documents.
Jump into concepts and practice - no test required
Imagine signing a paper letter with a unique pen that only you own. The receiver can check your signature to be sure the letter is really from you and that no one erased or changed your words.
┌───────────────┐ ┌───────────────┐ ┌───────────────┐
│ Sender │ │ Message │ │ Receiver │
│ (Private Key) │──────▶│ + Signature │──────▶│ (Public Key) │
└───────────────┘ └───────────────┘ └───────────────┘
│ │ │
│ Create hash │ │
│ Sign hash │ │
│ │ │
│ │ Verify signature │
│ │◀──────────────────────┤
│ │ │
│ │ Check hash matches │
│ │ │digital signature in cybersecurity?def verify_signature(message, signature, public_key):
hashed = hash_function(message)
decrypted_hash = decrypt(signature, public_key)
return hashed == decrypted_hash
message = "Hello"
signature = encrypt(hash_function(message), private_key)
result = verify_signature(message, signature, public_key)
print(result)def create_signature(message, private_key):
encrypted_message = encrypt(message, private_key)
return encrypted_message