February 2020
Beginner
621 pages
19h 34m
English
Suppose you want to encrypt the plaintext This is the plaintext with a shift of 3. We first encode it as an alphabetic string of capital letters with the spaces removed. Then we shift each letter by three positions:
S=ShiftCryptosystem(AlphabeticStrings())P=S.encoding("This is the plaintext")C=S.enciphering(3,P);C
When this is evaluated, we obtain the ciphertext
WKLVLVWKHSODLQWHAW
To decrypt, we can shift by or do the following:
S.deciphering(3,C)
When this is evaluated, we obtain
THISISTHEPLAINTEXT
Suppose we don’t know the key and we want to decrypt by trying all possible shifts:
S.brute_force(C)
Evaluation yields
0: WKLVLVWKHSODLQWHAW,1: VJKUKUVJGRNCKPVGZV,2: UIJTJTUIFQMBJOUFYU,
Read now
Unlock full access