You are on page 1of 8

CIPHERS

What Is Cipher And Types Of Ciphers

▪ Definition:
▪ In cryptography, a cipher (or cypher) is an algorithm for perform ing encryption or decryption—a
series of well-defined steps that can be followed as a procedure.

▪ Substitution Cipher
▪ Hiding som e data is known as encryption. When plain text is encrypted it becom es unreadable and
is known as ciphertext. In a Substitution cipher, any character of plain text from the given fixed set
of characters is substituted by som e other character from the sam e set depending on a key. For
exam ple with a shift of 1, A would be replaced by B, B would becom e C, and so on.

▪ Transposition Cipher

▪ simple data encryption scheme in wh ich plaintext ch aracters are sh ifted in som e regular pattern to
form ciphertext
Substitution Cipher

1. Caeser Cipher
2. Vigener Cipher
3. Poly Alphabetic Cipher
Caeser Cipher

▪ The Caesar Cipher technique is one of the earliest and simplest methods of
encryption technique. It’s simply a type of substitution cipher, i.e., each letter of a
given text is replaced by a letter with a fixed number of positions down the alphabet.
For example with a shift of 1
▪ Write a brute force program for caeser cipher
Example

Text : ABCDEFGHIJKLMNOPQRSTUVWXYZ
Shift: 23
Cipher: XYZABCDEFGHIJKLMNOPQRSTUVW

Text : ATTACKATONCE
Shift: 4
Cipher: EXXEGOEXSRGI
Encryption:
En(x) = (x+n)mod26
Decryption:
En(x) = (x-n)mod26
Caeser Cipher

Advantages
Disadvantages
▪ Easy to implement and use thus, making ▪ It is not secure against modern
suitable for beginners to learn about decryption methods.
encryption.
▪ Vulnerable to known-plaintext attacks,
▪ Can be physically implemented, such as where an attacker has access to both
with a set of rotating disks or a set of the encrypted and unencrypted versions
cards, known as a scytale, which can be of the same messages.
useful in certain situations.
▪ The small number of possible keys
▪ Requires only a small set of pre-shared means that an attacker can easily try all
information. possible keys until the correct one is
▪ Can be modified easily to create a more found, making it vulnerable to a brute
secure variant, such as by using a force attack.
multiple shift values or keywords.
Vigenère Cipher

▪ Vigenère Cipher is a method of encrypting alphabetic text. It uses a simple form of


polyalphabetic substitution. A polyalphabetic cipher is any cipher based on
substitution, using multiple substitution alphabets. The encryption of the original
text is done using the Vigenère square or Vigenère table.
Example
Input : Plaintext : GEEKSFORGEEKS
Keyword : AYUSH
Output : Ciphertext : GCYCZFMLYLEIM
For generating key, the given keyword is repeated
in a circular m anner until it m atches the length of
the plain text.
The keyword "AYUSH" generates the key "AYUSHAYUSHAYU"

Encryption
The plaintext(P) and key(K) are added m odulo 26.
Ei = (Pi + Ki) m od 26

Decryption
Di = (Ei - Ki + 26) m od 26

You might also like