Professional Documents
Culture Documents
CS Lab Notes-1
CS Lab Notes-1
Caesar cipher is the earliest Classical Encryption algorithm that follows Substitution technique. That is,
each letter in the plain text is substituted by a predefined number of alphabet positions (usually 3). The
algorithm can be depicted using the following table:
Decryption is done using the formula: P= Ek(C) mod 26, where C is the Cipher Text and P is the Plain Text.
We can modify the Caesar Cipher by altering the function of the key for substitution. Caesar Cipher is
implemented by using k=3. For modified Caesar Cipher we can alter the value and the functioning of the
key viz. decrease the key value for encryption and increase the key value for decryption, etc.
2. ONE TIME PAD
The Vernam Cipher, also called as One-Time Pad is implemented using a random set of non-repeating
characters as the input cipher text. The most significant point here is that once an input cipher text for
transposition is used, it is never used again for any other message( hence the name One-pad). The
length of the input cipher text is equal to the length of the original plain text.
1. Plain Text H O W A R E Y O U
7 14 22 0 17 4 24 14 20
2. One-time pad N C M T Z Q A R X
13 2 1 19 25 16 0 17 23
________________________________________________________________
3. Initial Total 20 16 23 19 42 20 24 31 43
4. Subtract 26, if
Number > 25 20 16 23 19 16 20 24 5 17
5. Cipher Text U Q X T Q U Y F R
3. RAIL FENCE TRANSPOSITION TECHNIQUE
Rail Fence is a Classical Encryption Algorithm that uses Transposition Technique to carry out
encryption. The algorithm proceeds by placing the plain text downwards and diagonally on
successive “rails” or depths of an imaginary fence, then moving up when the bottom rail is
reached. When the top rail is reached, the message is written downwards again until the whole
plaintext is written out. The message is then read off in rows. For example, if we consider3
"rails" and the message 'WE ARE DISCOVERED. FLEE AT ONCE' is used, the given plain text
is writes out as:
WECRLTEERDSOEEFEAOCAIVDEN
4. IMPLEMENTATION OF RSA ALGORITHM
RSA algorithm is asymmetric cryptography algorithm proposed by Rivest, Shamir and Adleman.
Asymmetric actually means that it works on two different keys i.e. Public Key and Private
key. As the name describes that the Public Key is given to everyone and Private key is kept
private. The idea of RSA is based on the fact that it is difficult to factorize a large integer. The
public key consists of two numbers where one number is multiplication of two large prime
numbers. And private key is also derived from the same two prime numbers. So if somebody can
factorize the large number, the private key is compromised. Therefore encryption strength totally
lies on the key size and if we double or triple the key size, the strength of encryption increases
exponentially. RSA keys can be typically 1024 or 2048 bits long, but experts believe that 1024
bit keys could be broken in the near future. But till now it seems to be an infeasible task.
The Algorithm:
1. Each user generates a public/private key pair by selecting two large primes at random p, q
OpenSSL is a cryptography toolkit implementing the Secure Sockets Layer (SSL v2/v3)
and Transport Layer Security (TLS v1) network protocols and related cryptography
standards required by them.
The openssl program is a command line tool for using the various cryptography functions
of OpenSSL's crypto library from the shell. It can be used for: