Study Atlas › Computer Science › Security

Hash functions and digital signatures

Cryptographic hashes give fixed-size fingerprints of data; signatures prove who signed it and that it was not altered.

Edited by Alex C, EduAlx · Sources cited below

Explanation

Good hashes (SHA-256, SHA-3) are pre-image and collision resistant; MD5 and SHA-1 are broken for collisions. Digital signatures (RSA, ECDSA, Ed25519) sign a hash with a private key; anyone verifies with the public key. Certificates and PKI bind keys to identities, enabling HTTPS.

Example

SHA-256('abc') starts ba7816bf…

Code

import hashlib
print(hashlib.sha256(b'abc').hexdigest())

How it works, step by step

  1. Hash the message
  2. Sign the hash with the private key
  3. Send message + signature
  4. Receiver hashes and verifies with the public key

Open the interactive page with diagrams →

People behind it

References

  1. NIST FIPS 180-4, Secure Hash Standard, 2015.
  2. NIST FIPS 186-5, Digital Signature Standard, 2023.

Textbooks

Related topics

Public-key cryptography (Diffie–Hellman, RSA)Computer security fundamentals (CIA triad)Web development: front end and back endSearch engines and PageRankDistributed systems: CAP theorem and consensusComputer vision and convolutional neural networksCloud computingNatural language processingVirtualisation and containersReinforcement learning