Cryptography
Cryptography is the technique of securing information by converting it into an unreadable form
(ciphertext) so that only authorized users can access it.
What is Cipher?
A cipher is a technique that is used in transforming the readable data
(plaintext) into coded data (ciphertext) and the other way round. The first
step in converting regular text into an unrecognizable form is encryption
and the process of converting the encoded text back into regular text is
decryption. Ciphers are able to perform these transformation using keys;
specific pieces of information. It guarantees that only the right person
can get to the primary data.
Cip
her working
Primary Terminologies
Cipher: A method or a set of rules for performing encryption or
decryption of information – a step by step process.
Encryption: The transformation of plaintext to the ciphertext through
the use of a cipher.
Decryption: The act of moving from the encrypted text to the original
text.
Plaintext: The source or plain data or text that has to be converted
into cipher text before sending it over a channel.
Ciphertext: The coded message that cannot be comprehended in its
original form without the usage of decryption.
Key: An item of data that a cipher employs to engage in the
conversion of plaintext into ciphertext and vice versa.
How Ciphers Work?
Ciphers work by rearranging readable information (plaintext) in another
form of information called ciphertext by use of a process that is known as
encryption and this involves use of a certain key. Shifting of the plaintext
is controlled by this key which operates like a password. Decryption is
the process of recuperating the initial text from the cipher-text, which can
be done only having the right key. This entitles the information to be
secured and released to the right personnel only. Various ciphers like
substitution ciphers, transposition ciphers and the modern algorithms
employed in the contemporary AES and RSA modes, employ these
methods to perform the above transformation to improve security
depending on the complexity of the key and the algorithm in use.
What are Ciphers Used for?
Ciphers have a wide range of applications across various fields to
ensure the security and integrity of information:
Secure Communications: Encryption of emails, instant messages,
and VoIP convert messages to codes that cannot be understandable
to an unauthorized person and thus allow only the target receiver to
be able to read the message.
Protect Financial Transactions: Secure Internet connection, which
is applied in online banking and e-commerce, uses encryption to
safeguard consumers’ private data and, in particular, their credit card
numbers and other personal data, against scammers.
Safeguard Data Storage: Encryption is applied for safeguard of data
which is stored in devices, servers and even in cloud. This
guarantees that even in cases where the disks on which data is
stored are lost or mobile phone is stolen, the content of it cannot be
accessed without the Decryption Key.
Ensure Authentication: The authentication protocols entail the use
of encryption to be able to identify the user and or devices. It also
assist in avoiding fraudulent communications and transaction, thereby
securing the communications from unauthorized access.
Enable Secure Digital Signatures: Digital signals are implemented
using encryption to reduce the reliability of documents and messages
that are transmitted electronically. This makes sure that it has not
been interfered with and that it is original from the source that has the
information.
Types of Ciphers
Ciphers can be broadly classified into three categories: Among the types
of ciphers there are substitution ciphers, transposition ciphers, and
modern ciphers.
1. Substitution Ciphers
Substitution ciphers involve replacing each member of the plaintext with
another member which can be of the same set. One of the early
examples of the substitution technique is the Caesar cipher that got its
name from Julius Caesar, who allegedly employed it in his secret letters.
Caesar Cipher
The Caesar cipher is a substitution cipher where each letter in the
plaintext is replaced by another letter shifted a fixed number of positions
down the alphabet.
2. Transposition Ciphers
Transposition ciphers are those forms of ciphers that work on the
principle of shifting the positions of the characters of the plaintext to
create the ciphertext. While in substitution ciphers the actual letters are
replaced, in transposition ciphers the letters’ positions are changed
instead.
Rail Fence Cipher
In the Rail Fence Cipher, the plaintext is arranged in a manner of a
zigzag pattern on the number of ‘rails’ and then read row-wise.
Columnar Transposition Cipher
In Columnar Transposition Cipher, the plaintext is written into rows under
a certain key. The columns are then arranged in order of the key names
by using the sort function.
Caesar cipher
The Caesar cipher is a simple encryption technique that was used by Julius
Caesar to send secret messages to his allies. It works by shifting the letters
in the plaintext message by a certain number of positions, known as the
"shift" or "key". The Caesar Cipher technique is one of the earliest and
simplest methods of encryption techniques.
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, A would be replaced by B, B would become C,
and so on. The method is apparently named after Julius Caesar, who
apparently used it to communicate with his officials.
Cryptography Algorithm For the Caesar Cipher
Thus to cipher a given text we need an integer value, known as a shift
which indicates the number of positions each letter of the text has been
moved down.
The encryption can be represented using modular arithmetic by first
transforming the letters into numbers, according to the scheme, A = 0, B
= 1,..., Z = 25. Encryption of a letter by a shift n can be described
mathematically as.
For example, if the shift is 3, then the letter A would be replaced by the
letter D, B would become E, C would become F, and so on. The
alphabet is wrapped around so that after Z, it starts back at A.
Here is an example of how to use the Caesar cipher to encrypt the
message "HELLO" with a shift of 3:
1. Write down the plaintext message: HELLO
2. Choose a shift value. In this case, we will use a shift of 3.
3. Replace each letter in the plaintext message with the letter that is three
positions to the right in the alphabet.
H becomes K (shift 3 from H)
E becomes H (shift 3 from E)
L becomes O (shift 3 from L)
L becomes O (shift 3 from L)
O becomes R (shift 3 from O)
[Link] encrypted message is now "KHOOR".
To decrypt the message, you simply need to shift each letter back by the
same number of positions. In this case, you would shift each letter in
"KHOOR" back by 3 positions to get the original message, "HELLO".
En(x)=(x+n)mod 26 En(x)=(x+n)mod 26
(Encryption Phase with shift n)
Dn(x)=(x−n)mod 26 Dn(x)=(x−n)mod 26
(Decryption Phase with shift n)
Examples :
Text : ABCDEFGHIJKLMNOPQRSTUVWXYZ
Shift: 23
Cipher: XYZABCDEFGHIJKLMNOPQRSTUVW
Text : ATTACKATONCE
Shift: 4
Cipher: EXXEGOEXSRGI
Advantages
Easy to implement and use thus, making suitable for beginners to learn
about encryption.
Can be physically implemented, such as with a set of rotating disks or a
set of cards, known as a scytale, which can be useful in certain
situations.
Requires only a small set of pre-shared information.
Can be modified easily to create a more secure variant, such as by
using a multiple shift values or keywords.
Disadvantages
It is not secure against modern decryption methods.
Vulnerable to known-plaintext attacks, where an attacker has access to
both the encrypted and unencrypted versions of the same messages.
The small number of possible keys means that an attacker can easily try
all possible keys until the correct one is found, making it vulnerable to a
brute force attack.
It is not suitable for long text encryption as it would be easy to crack.
It is not suitable for secure communication as it is easily broken.
Does not provide confidentiality, integrity, and authenticity in a
message.
Features of Caesar Cipher
1. Substitution cipher: The Caesar cipher is a type of substitution cipher,
where each letter in the plaintext is replaced by a letter some fixed
number of positions down the alphabet.
2. Fixed key: The Caesar cipher uses a fixed key, which is the number of
positions by which the letters are shifted. This key is known to both the
sender and the receiver.
3. Symmetric encryption: The Caesar cipher is a symmetric
encryption technique, meaning that the same key is used for both
encryption and decryption.
4. Limited keyspace: The Caesar cipher has a very limited keyspace of
only 26 possible keys, as there are only 26 letters in the English
alphabet.
5. Vulnerable to brute force attacks: The Caesar cipher is vulnerable
to brute force attacks, as there are only 26 possible keys to try.
6. Easy to implement: The Caesar cipher is very easy to implement and
requires only simple arithmetic operations, making it a popular choice for
simple encryption tasks.
Rules for the Caesar Cipher
1. Choose a number between 1 and 25. This will be your "shift" value.
2. Write down the letters of the alphabet in order, from A to Z.
3. Shift each letter of the alphabet by the "shift" value. For example, if the
shift value is 3, A would become D, B would become E, C would
become F, and so on.
4. Encrypt your message by replacing each letter with the corresponding
shifted letter. For example, if the shift value is 3, the word "hello" would
become "khoor".
5. To decrypt the message, simply reverse the process by shifting each
letter back by the same amount. For example, if the shift value is 3, the
encrypted message "khoor" would become "hello".
Algorithm for Caesar Cipher
Input:
1. Choose a shift value between 1 and 25.
2. Write down the alphabet in order from A to Z.
3. Create a new alphabet by shifting each letter of the original alphabet by
the shift value. For example, if the shift value is 3, the new alphabet
would be:
4. A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
DEFGHIJKLMNOPQRSTUVWXYZABC
5. Replace each letter of the message with the corresponding letter from
the new alphabet. For example, if the shift value is 3, the word "hello"
would become "khoor".
6. To decrypt the message, shift each letter back by the same amount. For
example, if the shift value is 3, the encrypted message "khoor" would
become "hello".
Transposition Cipher
The Transposition Cipher Technique is an encryption method used to
encrypt a message or information. This encryption method is done by
playing with the position of letters of the plain text. The positions of the
characters present in the plaintext are rearranged or shifted to form the
ciphertext. It makes use of some kind of permutation function to achieve
the encryption purpose. It is very easy to use and so simple to implement.
Types of Transposition Cipher Techniques
There are three types of transposition cipher techniques
Rail Fence Transposition Cipher
Block (Single Columnar) Transposition Cipher
Double Columnar Transposition Cipher
Rail Fence Transposition Cipher
Rail Fence Transposition cipher technique is the simplest transposition
cipher its. It is also termed as a zigzag cipher. It gets its name from the
way through which it performs encryption of plain text. The steps to get
cipher text with the help of the Rail Fence Transposition cipher technique
are as follow-
Technique of Rail Fence Transposition Cipher
Example: The plain text is "Hello Krishna"
Now, we will write this plain text in the diagonal form:
Rail Fence Transposition Cipher
Now, following the second step we get our cipher text.
Cipher Text = "rsnelkiha"
Block (Single Columnar) Transposition Cipher
Block Transposition Cipher is another form of Transposition Cipher which
was used to encrypt the message or information. In this technique, first, we
write the message or plaintext in rows. After that, we read the message
column by column. In this technique, we use a keyword to determine the no
of rows.
Step 1: First we write the message in the form of rows and columns, and
read the message column by column.
Step 2: Given a keyword, which we will use to fix the number of rows.
Step 3: If any space is spared, it is filled with null or left blank or in by
(_).
Step 4: The message is read in the order as specified by the keyword.
Block Columnar Transposition Cipher
For example: The plaintext is "KRISHNA RANJAN"
Now we will write the plaintext in the form of row and column.
Cipher Text = IAN_RNANS_J_KHRA
Double Columnar Transposition Cipher
Double Columnar Transposition Cipher is another form of Transposition
Cipher Technique. The main objective of using a Double Columnar
Transposition Cipher is to encrypt the message twice. It makes use of the
Single Columnar Transposition technique but uses two times. It can use the
same or different secret keys. The output obtained from the first encryption
will be the input to the second encryption.
Step 1: Write the plaintext row-wise in a matrix using the first keyword
length as columns
Step 2: Assign column numbers based on alphabetical order of the first
keyword
Double Columnar Transposition Cipher
Step 3: Read columns in that order to get the first ciphertext
Now applying keyword 2:
Step 4: Write this ciphertext again row-wise using the second keyword
Now apply step 3:
Step 5: Assign column order based on the second keyword.
Step 6: Read columns accordingly to obtain the final ciphertext
Double Columnar Transposition Cipher