All Categories

Cryptography & Security

Keeping secrets safe: modular arithmetic, RSA, entropy, hashing and error-correcting codes

Cryptography & Security brings together the formulas that keep data private, verify identities, and detect mistakes, from modular arithmetic and RSA to entropy, hashing, and error-correcting codes. It’s useful for students revising for exams, as well as anyone working with secure systems, passwords, or communications, because these formulas explain how modern protection works and how strong it really is.

Modular Exponentiation

NEWIntermediate
c=me mod nc = m^e \bmod n

Core operation of RSA encryption — raise a message to a power, modulo n.

View details

RSA Decryption

NEWAdvanced
m=cd mod nm = c^d \bmod n

Recovers the message using the private exponent d.

View details

Euler's Totient

NEWIntermediate
φ(n)=(p−1)(q−1)\varphi(n) = (p-1)(q-1)

Counts integers below n coprime to it, for n = pq — used to make RSA keys.

View details

Shannon Entropy

NEWAdvanced
H=−∑ipilog⁡2piH = -\sum_i p_i \log_2 p_i

Average information content — and the theoretical strength of a random source.

View details

Password Entropy

NEWIntermediate
H=Llog⁡2RH = L \log_2 R

Bits of security from password length and character-set size.

View details

Key Space Size

NEWIntermediate
K=2bK = 2^b

Number of possible keys for a b-bit key.

View details

Birthday Bound

NEWAdvanced
n≈1.1772bn \approx 1.177\sqrt{2^b}

Collisions become likely after about √ of the hash space.

View details

Hamming Distance

NEWBasic
d(x,y)=∑i[xi≠yi]d(x,y) = \sum_i [x_i \ne y_i]

Number of positions at which two strings differ.

View details

Hamming Code Parity Bits

NEWAdvanced
2r≥m+r+12^r \ge m + r + 1

Minimum parity bits r needed to protect m data bits.

View details

XOR Cipher

NEWBasic
c=m⊕kc = m \oplus k

Bitwise XOR of message and key; XOR again with k to decrypt.

View details

Diffie–Hellman Shared Secret

NEWAdvanced
s=Ba mod ps = B^a \bmod p

Two parties derive the same secret over a public channel.

View details

Brute-Force Time

NEWIntermediate
t=Krt = \frac{K}{r}

Time to try every key at a given guess rate.

View details

Avalanche Effect Target

NEWAdvanced
E[Δ]=n2E[\Delta] = \frac{n}{2}

A good hash flips about half its output bits when one input bit changes.

View details

Caesar Cipher Shift

NEWBasic
c=(m+k) mod 26c = (m + k) \bmod 26

Shift each letter forward by k positions.

View details

Collision Probability

NEWAdvanced
P≈n22NP \approx \frac{n^2}{2N}

Approximate chance of a collision among n items in space N.

View details