Cryptographic Algorithm
Cryptographic Algorithm
Algorithms
Types of Algorithm
• Secret Key (Symmetric Key) Algorithm
• Public Key (Asymmetric Key) Algorithm
Secret Key Cryptography
• Using a single key for encryption/decryption.
• The plaintext and the cipher text having the same
size
Alice Bob
encrypt mA using eB encrypt mA using dB
Classical Encryption Techniques
• Substitution cipher
Replacing each element of the plaintext with
another element.
• Transposition (or permutation) cipher
Rearranging the order of the elements of the
plaintext.
Substitution Ciphers
Caeser Cipher:
• Earliest known substitution cipher
• Invented by Julius Caesar
• Each letter is replaced by the letter three
positions further down the alphabet.
• Example: ohio state RKLR VWDWH
Caeser Cipher
• Mathematically, map letters to numbers:
a, b, c, ..., x, y, z
0, 1, 2, ..., 23, 24, 25
• Then the general Caesar cipher is:
c = EK(p) = (p + k) mod 26
p = DK(c) = (c – k) mod 26
Monoalphabetic Cipher
• Shuffle the letters and map each plaintext letter to a
different random ciphertext letter:
Plaintext: ifwewishtoreplaceletters
Ciphertext: WIRFRWAJUHYFTSDVFSFUUFYA
• Now we have a total of 26! = 4 x 1026 keys.
• With so many keys, it is secure against brute-force
attacks.
• Playfair Cipher
• Polyalphabetic Substitution Cipher
Vigenere Cipher
Caeser Cipher Implementation
• https://repl.it/
#taking the input from user