Simulation Notes
Letter Mapping
A=0, B=1, ..., Z=25. Ex: H=7 (ord('H')-ord('A')).
Block Division
4 letters/block.
Pad short final block with X (23).
Ex: "HELLOCRYPTOGRAPHY" → Blocks: HEL L, OCR Y, PTO G, RAPH Y (pad if needed).
Encryption Formula
C=(P+K)mod 26C=(P+K)mod26
P = plaintext number.
K = key (usually 3).
C → letter (C + ord('A')).
Ex: H(7) +3 =10 mod26=10 → K.
Decryption Formula
P=(C−K)mod 26P=(C−K)mod26
Ex: K(10) -3 =7 mod26=7 → H.
Step-by-Step Example: "HELLO"
Numbers: H=7, E=4, L=11, L=11, O=14.
Block1: HELL → 7,4,11,11.
Encrypt: 7+3=10(K), 4+3=7(H), 11+3=14(O), 11+3=14(O) → "KHOO".
Decrypt back: K(10)-3=7(H), etc. → "HELL".
Practice Exercise: "INTEGRATIVE"
Numbers: I=8,N=13,T=19,E=4,G=6,R=17,A=0,T=19,I=8,V=21,E=4.
Blocks: INTE GRAT IVE (pad? 10 letters → INTE, GRAT, IVE +X? Check length).
Encrypt each +3 mod26.
Expected ciphertext: Compute step-by-step (L Q W H J T D W L Y).