By Bonaventure Ogeto · Published · Last verified:

Symmetric vs Asymmetric Encryption, Hashing and Digital Signatures

The short answer

Symmetric encryption uses one shared key and protects the data itself; asymmetric encryption uses a public and private key pair to agree or send that key; hashing makes a one-way fingerprint with no key; and digital signatures prove who sent data. Real systems combine all four, and quantum computers seriously threaten only the public-key parts.

Source: Mctaba Labs, “Symmetric vs Asymmetric Encryption, Hashing and Digital Signatures”, last verified 4 December 2026, mctaba.com/learn/cryptography/symmetric-vs-asymmetric-encryption-hashing-signatures

What are the four building blocks of cryptography?

Modern security is assembled from four tools, and most systems use all four together.

Building blockWhat it doesExample algorithmsWhere you meet itQuantum impact
Symmetric encryptionScrambles data with one secret key both sides share; the same key decryptsAES, standardised as FIPS 197[1]; DES before itThe data inside every TLS connection, encrypted disks and databases, end-to-end encrypted chatsSmall: NIST expects AES-128 to remain secure for decades[2] and does not expect to replace[3] its symmetric standards
Asymmetric encryption and key exchangeUses a public and private key pair to send or agree a secret key over an open networkRSA, Diffie-Hellman, elliptic-curve Diffie-Hellman (X25519), and now ML-KEMTLS handshakes, the Signal Protocol behind WhatsAppSevere: RSA and ECDH are no longer secure[4] against a large quantum computer
HashingTurns any input into a short, fixed-size fingerprint; one-way and keylessSHA-256 from FIPS 180-4[5], SHA-3 from FIPS 202[6]Download checks, password storage, blockchains, inside signatures and HMACsSmall: SHA-256 can also continue to be used[7], per the NCSC
Digital signaturesProve who signed data and that it has not changed; the private key signs, the public key verifiesRSA, ECDSA, EdDSA, Schnorr (BIP 340[8]); post-quantum ML-DSA and SLH-DSATLS certificates, software updates, Bitcoin transactionsSevere for today's schemes; the replacements are standardised in FIPS 204 and FIPS 205[9]

Two more terms recur. A key-encapsulation mechanism (KEM) is NIST's name for a set of algorithms two parties can use to establish a shared secret key over a public channel[10]; it is a form of asymmetric cryptography. A message authentication code (MAC), such as HMAC, is a keyed hash: symmetric, but used for authentication rather than secrecy.

What is symmetric encryption?

Symmetric encryption uses the same secret key to encrypt and to decrypt. The simplest example is the Caesar cipher, which, according to Suetonius, replaced each letter with the one three places further along the alphabet[11]; the key is the size of the shift.

The standard today is AES, the Advanced Encryption Standard, published as FIPS 197 on 26 November 2001[1] after an open competition: the US Commerce Department named Rijndael, by the Belgian cryptographers Joan Daemen and Vincent Rijmen, the winner on 2 October 2000[12]. AES encrypts data in 128-bit blocks[1] and comes in three key sizes: AES-128, AES-192 and AES-256. Its predecessor, DES, first published as a standard in January 1977[13], was withdrawn in May 2005[14].

Symmetric ciphers are fast, so they carry the actual data in almost every secure system. Their weakness is the key: both sides need the same secret first, and anyone who gets it can read everything.

What is asymmetric encryption?

Asymmetric, or public-key, encryption uses two different keys: a public key that can be shared with anyone and a private key that its owner keeps. Diffie and Hellman described the idea in November 1976[15]: separate keys for enciphering and deciphering, with the deciphering key computationally infeasible[15] to work out from the enciphering one. RSA, published in February 1978[16], made it practical; its security rests in part on the difficulty of factoring[17] a large number that is the product of two secret primes.

Systems rarely use public-key encryption for bulk data. Instead they use it to agree or deliver a symmetric key, which then does the heavy work. The post-quantum ML-KEM, standardised as FIPS 203[9], is a KEM built for exactly that job. How Diffie-Hellman and RSA work, with everyday analogies, is in public-key cryptography explained.

What is the difference between symmetric and asymmetric encryption?

Symmetric encryptionAsymmetric encryption
KeysOne shared secret keyA public key and a private key
Main jobEncrypting the data itselfAgreeing or delivering keys, and signing
Getting the key to the other sideBoth sides must already have itThe public key can be published openly
ExamplesAES, formerly DESRSA, Diffie-Hellman, elliptic curves, ML-KEM
Quantum riskLow: keys of at least 128 bits stay usable[7]High: Shor's algorithm would break RSA and elliptic curves[4]

Use both, each for its own job: asymmetric cryptography solves the key problem and symmetric cryptography protects the data.

What is hashing, and how is it different from encryption?

A hash function turns any input, whether a password, a file or a whole disk image, into a short fixed-size value called a hash or digest. The same input always gives the same hash, a tiny change gives a completely different one, and there is no key and no way back. Encryption is reversible by design for whoever holds the key; hashing is not reversible at all.

That makes hashes ideal fingerprints for checking files, chaining blocks and building signatures and HMACs. The workhorse is SHA-256, part of the SHA-2 family in the Secure Hash Standard, FIPS 180-4[5]; SHA-3 followed as FIPS 202 in August 2015[6]. NIST's transition report gives SHA-256 128 bits of collision security and 256 bits of preimage security[3]. Collision security measures how hard it is to find two inputs with the same hash; preimage security, how hard it is to find an input that produces a given hash. The old SHA-1 is on its way out: NIST says it is deprecated for all remaining technical applications and will be disallowed in FIPS-validated modules after 2030[3].

Passwords are where the difference matters most. Never store them encrypted, because anyone who steals the key can decrypt every one. Do not store them as plain fast hashes either, because attackers can test guesses at enormous speed. Use a deliberately slow, salted password-hashing function; a salt is a random value stored with each hash so that identical passwords look different. Cybersecurity basics for new developers covers the practical choice.

What is a digital signature, and is an HMAC the same thing?

A digital signature proves two things: who signed a piece of data, and that it has not changed since. The signer uses a private key and anyone can verify with the matching public key. NIST describes signature schemes as used “to detect unauthorized modifications to data and to authenticate the identity of the signatory”[9]. Signatures protect the certificates that tell your browser a site is genuine, the updates your phone installs and every Bitcoin transaction. Bitcoin has traditionally used ECDSA signatures over the secp256k1 curve[8], and BIP 340, now marked Deployed, specifies 64-byte Schnorr signatures[8] on the same curve.

An HMAC looks similar but works differently. It is a keyed hash: sender and receiver share one secret, and the sender hashes the message together with it. Anyone with the secret can check the result and nobody without it can forge it, but because both sides hold the same key, it cannot show which of the two sent the message. It is symmetric authentication, not a true digital signature.

Paystack's webhooks are a familiar example for developers in Kenya. Paystack calls it a signature, but its documentation says the x-paystack-signature header is an HMAC SHA512 signature of the raw request body, signed with your secret key[18], with no timestamp. Its newer Paystack-Signature header adds a timestamp, and Paystack tells merchants to reject events more than 300 seconds[18] off their server time and to compare signatures in constant time. Verifying the x-paystack-signature header correctly shows the code, and securing payment webhooks covers replays and idempotency.

How do the four building blocks work together?

Real systems chain them, as two everyday examples show.

A TLS 1.3 connection, the padlock in your browser and the link between a banking app and its servers. TLS 1.3 is now specified in RFC 9846[19], which replaced the original RFC 8446 of August 2018[20]. Client and server agree a fresh secret with elliptic-curve or finite-field Diffie-Hellman (asymmetric). The server signs the handshake with its certificate's private key (signature). Both sides hash the handshake messages so tampering shows (hashing), then encrypt the traffic with a symmetric cipher such as AES (symmetric). Because TLS 1.3 removed static RSA and Diffie-Hellman key exchange, all public-key based key exchange provides forward secrecy[19].

A WhatsApp chat. WhatsApp announced on 5 April 2016[21] that every call, message, photo, video, file and voice message, including group chats, is end-to-end encrypted by default. Its encryption white paper says the Signal Protocol is the basis, designed to stop third parties and WhatsApp itself from reading messages or calls, and that each device's long-term identity key is a Curve25519 key pair[22]. Public keys set up each conversation, and symmetric keys protect the messages: the white paper says each message key holds 32 bytes for an AES-256 key, 32 bytes for an HMAC-SHA256 key and 16 bytes for an initialisation vector[22], so AES keeps the message secret and the HMAC reveals tampering.

Kenyan law uses the same vocabulary: the Data Protection Act 2019 defines encryption as converting the content of any readable data using technical means into coded form[23]. How these tools protect M-Pesa, banking apps and WhatsApp is covered in how encryption protects you in Kenya.

How do quantum computers affect each building block?

Two quantum algorithms matter, and they hit very differently.

  • Shor's algorithm breaks the mathematics under today's public-key cryptography. NIST says it renders public-key systems based on factoring and discrete logarithms impotent[4]. RSA, Diffie-Hellman, elliptic-curve key exchange and today's signatures all fall in that group, and NIST will deprecate them after 2030 and disallow them after 2035[3].
  • Grover's algorithm only speeds up brute-force search. NIST's view is that if it ever becomes practical, doubling the key size will be sufficient[4], and its FAQ says AES-128 will remain secure for decades to come[2].

So symmetric encryption and hashing stay. NIST believes all its approved symmetric primitives with at least 128 bits of classical security meet its first post-quantum security category[3], and Google's Chrome team notes that in TLS the symmetric encryption is considered safe against quantum cryptanalysis, but the way the symmetric keys are created is not[24]. Bitcoin Optech draws the same line for Bitcoin: ECDSA keys would lose all security[25] to Shor's algorithm, while hashes such as SHA-256 would only have their strength reduced to its square root by Grover's.

The replacements are standardised: ML-KEM for key establishment (FIPS 203[9]), and ML-DSA and SLH-DSA for signatures (FIPS 204 and FIPS 205[9]). SLH-DSA is built from hash functions, and FIPS 205 says its security relies on the presumed difficulty of finding preimages for hash functions[26], so hashing becomes a foundation for post-quantum signatures too. Signatures are less urgent in one respect: NIST notes they are not vulnerable to harvest now, decrypt later attacks[3], but it still calls their migration urgent because it takes longer and needs more parties to coordinate.

Is AES-256 quantum safe? goes deeper on the symmetric side, and what is post-quantum cryptography explains the new public-key algorithms. The cryptography series hub connects the rest.

For developers: which building block should I use for each job?

Match the job to the tool, use a well-reviewed library, and never invent your own scheme.

  • Encrypting data: an authenticated symmetric mode such as AES-GCM, which encrypts and detects tampering in one step. For data in transit, use TLS 1.3 rather than building your own protocol.
  • Sending or agreeing a key: let TLS or your library's key agreement do it, and plan for hybrid post-quantum key exchange in new designs.
  • Checking that data has not changed by accident: a hash such as SHA-256. Do not use SHA-1 or MD5 for anything new.
  • Proving a message came from a holder of a shared secret (webhooks, service-to-service calls): an HMAC over the raw body, compared in constant time, with a timestamp check against replays.
  • Proving to anyone who signed something (releases, documents, tokens): a digital signature such as Ed25519 or ECDSA today, with a plan to move to ML-DSA.
  • Storing passwords: a slow, salted password-hashing function. Never encryption, never a bare fast hash.

The building blocks you call directly look like this in Node.js's built-in crypto module (key agreement is usually left to TLS):

building-blocks.mjs
import {
  createHash, createCipheriv, randomBytes,
  generateKeyPairSync, sign, verify, scryptSync,
} from 'node:crypto';

const message = Buffer.from('order 1042 paid');

// Hashing: a fixed-size fingerprint, no key, no way back
const digest = createHash('sha256').update(message).digest('hex');

// Symmetric encryption: one shared key; GCM also detects tampering.
// Never reuse an IV with the same key.
const key = randomBytes(32);
const iv = randomBytes(12);
const cipher = createCipheriv('aes-256-gcm', key, iv);
const ciphertext = Buffer.concat([cipher.update(message), cipher.final()]);
const authTag = cipher.getAuthTag();

// Digital signature: the private key signs, anyone with the public key verifies.
// Ed25519 is quantum-vulnerable, like RSA and ECDSA.
const { publicKey, privateKey } = generateKeyPairSync('ed25519');
const signature = sign(null, message, privateKey);
const valid = verify(null, message, publicKey, signature);

// Passwords: never encrypt them; store a slow, salted hash with its salt
const salt = randomBytes(16);
const passwordHash = scryptSync('the user password', salt, 64);

Keep algorithm names in configuration, not scattered through code, so you can swap them when standards change.

Frequently asked questions

Is AES symmetric or asymmetric?
Symmetric. AES uses the same secret key to encrypt and decrypt. It was published as FIPS 197 in November 2001[1] and comes in three key sizes: AES-128, AES-192 and AES-256.
Is RSA symmetric or asymmetric?
Asymmetric. RSA uses a public key to encrypt or verify and a private key to decrypt or sign. Its security rests in part on the difficulty of factoring[17] a large number, which a large quantum computer running Shor’s algorithm could do.
Is hashing the same as encryption?
No. Encryption can be reversed by anyone holding the right key; hashing is one-way and cannot be turned back into the input. Use encryption to keep data secret and hashing to check that data has not changed.
Is an HMAC a digital signature?
Not in the strict sense. An HMAC uses one secret shared by sender and receiver, so it proves a message came from someone holding that secret. A digital signature uses a private key only the signer holds, and anyone can verify it with the public key. Paystack’s webhook “signature” is an HMAC.
Should passwords be encrypted or hashed?
Hashed, with a slow, salted password-hashing function such as bcrypt or scrypt. Anyone who steals the key can recover encrypted passwords, and plain fast hashes such as SHA-256 let attackers test guesses too quickly.
Which building blocks will quantum computers break?
The public-key ones: RSA, Diffie-Hellman, elliptic-curve key exchange and today’s digital signatures. Symmetric ciphers and hash functions survive at adequate sizes; the UK’s NCSC says symmetric algorithms with at least 128-bit keys, such as AES, can continue to be used[7].

Sources

  1. [1] NIST Computer Security Resource Center, 26 November 2001, checked 4 December 2026
  2. [2] NIST CSRC, 18 November 2018, checked 4 December 2026
  3. [3] NIST, October 2026, checked 4 December 2026
  4. [4] NIST, April 2016, checked 4 December 2026
  5. [5] NIST CSRC, August 2015, checked 4 December 2026
  6. [6] NIST CSRC, August 2015, checked 4 December 2026
  7. [7] UK National Cyber Security Centre (NCSC), 14 August 2024, checked 4 December 2026
  8. [8] Bitcoin Improvement Proposals repository (github.com/bitcoin/bips), 19 January 2020, checked 4 December 2026
  9. [9] NIST CSRC, 13 August 2024, checked 4 December 2026
  10. [10] NIST CSRC, September 2025, checked 4 December 2026
  11. [11] LacusCurtius (Bill Thayer, University of Chicago), Loeb Classical Library translation, 1913, 1913, checked 4 December 2026
  12. [12] NIST, 2 October 2000, checked 4 December 2026
  13. [13] NIST Computer Security Resource Center, 15 January 1977, checked 4 December 2026
  14. [14] NIST Computer Security Resource Center, 25 October 1999, checked 4 December 2026
  15. [15] IEEE Transactions on Information Theory (copy on Martin Hellman's Stanford page), November 1976, checked 4 December 2026
  16. [16] Communications of the ACM (scan on Ronald Rivest's MIT page), February 1978, checked 4 December 2026
  17. [17] Rivest, Shamir and Adleman (author's copy on Ronald Rivest's MIT page), February 1978, checked 4 December 2026
  18. [18] Paystack (developer documentation), checked 4 December 2026
  19. [19] RFC Editor (IETF), July 2026, checked 4 December 2026
  20. [20] RFC Editor (IETF), August 2018, checked 4 December 2026
  21. [21] WhatsApp (blog), 5 April 2016, checked 4 December 2026
  22. [22] WhatsApp (Meta), WhatsApp Encryption Overview technical white paper, 30 October 2026, checked 4 December 2026
  23. [23] Republic of Kenya, Data Protection Act No. 24 of 2019 (Kenya Gazette Supplement No. 181), copy hosted by the Office of the Data Protection Commissioner, 11 November 2019, checked 4 December 2026
  24. [24] Google (Chromium Blog), 10 August 2023, checked 4 December 2026
  25. [25] Bitcoin Optech (topic page), checked 4 December 2026
  26. [26] NIST, 13 August 2024, checked 4 December 2026

Related guides