Cryptography
Keys, hashes and the trust chain
Symmetric cryptography uses one shared key: fast, but scaling is n(n-1)/2 keys and distribution is the hard part. AES (128/192/256-bit) is the standard; DES and 3DES are deprecated. Block cipher modes matter: ECB leaks patterns and should never be used; CBC, CTR and GCM are common, with GCM providing encryption and authentication together.
Asymmetric cryptography uses a key pair. Encrypt with the recipient's public key for confidentiality; sign with your own private key for authenticity, integrity and non-repudiation. RSA and ECC are encryption/signature algorithms (ECC gives equal strength with smaller keys); Diffie-Hellman is key exchange only - it does not encrypt data, and unauthenticated DH is vulnerable to man-in-the-middle.
Hashing provides integrity, not confidentiality. SHA-2 and SHA-3 are acceptable; MD5 and SHA-1 are broken. Salt defeats rainbow tables, HMAC provides keyed integrity, and slow key-derivation functions (bcrypt, PBKDF2, Argon2) are correct for password storage.
A digital signature is a hash encrypted with the signer's private key; verification uses the signer's public key. PKI supplies trust: the CA issues X.509 certificates binding identity to a public key, the RA verifies identity, and CRL/OCSP handle revocation. Key management includes escrow (recovery), split knowledge with dual control (M-of-N), and secure destruction - compromising the key defeats the algorithm entirely.
Trap: assuming asymmetric encryption protects bulk data. It is far too slow; we use a hybrid - asymmetric to exchange a symmetric session key, symmetric for the payload (that is TLS).
Worked example: prove an email came from Alice unaltered. Alice hashes the message and encrypts the hash with her private key; the recipient decrypts it with her public key and compares hashes.
Rule of thumb: private key signs and decrypts; public key verifies and encrypts.