Hashing & Encryption : Session 1
Kalika Prasad Mishra
CTO Codes For Tomorrow
Overview
Objective
Deep Dive
Part A — Hashing
The session opened by defining a cryptographic hash function as a deterministic algorithm that takes an input (or "message") of arbitrary length and returns a fixed-length output, called a hash value or digest. Participants worked through why this fixed-length property is useful regardless of whether the input is a single character or a 10 GB file, the output is always the same size (e.g., 256 bits for SHA-256).
The discussion then moved into the three core security properties every cryptographic hash function must satisfy:
- Pre-image resistance : Given a hash output
h, it should be computationally infeasible to find any inputmsuch thathash(m) = h. - Second pre-image resistance : Given an input
m1, it should be infeasible to find a different inputm2such thathash(m1) = hash(m2). - Collision resistance : It should be infeasible to find any two distinct inputs
m1andm2such thathash(m1) = hash(m2).
The group examined the historical progression of hash algorithms:
MD5 (now broken due to practical collision attacks), SHA-1 (deprecated after the SHAttered collision attack demonstrated by Google in 2017), and the SHA-2 family (SHA-256, SHA-512), which remains widely used today.
SHA-3, based on the Keccak sponge construction, was introduced as a structurally different alternative offering resilience against future attacks that might target the Merkle-Damgård construction used by SHA-2.
A live demonstration showed how flipping a single bit in the input (the "avalanche effect") completely changes the output hash reinforcing that hash functions are designed to make outputs appear random and unrelated to small input changes.
Practical applications discussed included password storage (and why salting is required to defend against rainbow table attacks), file integrity verification via checksums, and hashing's role as a building block for Merkle trees and blockchains, previewed for later sessions.
Part B — Encryption
The session then transitioned into encryption, contrasting the two major categories:
- Symmetric encryption, where the same key is used to both encrypt and decrypt data. AES (Advanced Encryption Standard) was used as the primary example, with a walkthrough of its block cipher structure operating on 128-bit blocks with key sizes of 128, 192, or 256 bits.
- Asymmetric (public-key) encryption, where a mathematically linked key pair a public key and a private key is used, allowing anyone to encrypt data with the public key while only the holder of the private key can decrypt it. RSA was used as the primary example.
Participants discussed the performance trade-off between the two: symmetric encryption is extremely fast and suitable for bulk data, while asymmetric encryption is computationally expensive but solves the key distribution problem you don't need to have shared a secret key in advance.
The session covered modes of operation for block ciphers:
- ECB (Electronic Codebook) insecure for most use cases because identical plaintext blocks produce identical ciphertext blocks, leaking structural patterns.
- CBC (Cipher Block Chaining) : Each block is XORed with the previous ciphertext block before encryption, removing the pattern-leakage problem but requiring careful handling of initialization vectors (IVs).
- GCM (Galois/Counter Mode) : The modern preferred mode, providing both confidentiality and built-in authentication (AEAD), preventing undetected tampering with ciphertext.
The concept of hybrid encryption was introduced as the practical solution used in almost every real-world secure system (including TLS): asymmetric encryption is used only to securely exchange a symmetric session key, and all bulk data is then encrypted using the fast symmetric cipher with that session key.
This directly previewed why Diffie-Hellman (the topic of Session 2) is so important it offers another way to establish that shared symmetric key.
Key management challenges were discussed as a closing point: how keys should be generated, stored, rotated, and revoked, and why poor key management not weak algorithms is one of the most common causes of real-world cryptographic failures.