Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 8

CYBER SECURITY AND DATA ANALYTICS LAB

Cyber Security Experiments:

1. Implementation of Modified Caesar Cipher.


2. Implementation of One Time Pad Algorithm.
3. Implementation of Rail Fence Algorithm.
4. Implementation of RSA Algorithm.
5. Generating 10 passwords of length 12 characters using OPENSSL command.

Big Data Analytics Experiments:

1. Word Count Program using Map Reduce Program.


2. Implementing Matrix Multiplication with Hadoop Map Reduce.
3. Map Reduce program to find average of numbers.
4. Setting up and installing Hadoop.
1. MODIFIED CAESAR CIPHER

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:

Plain Text : abcdefghijklmnopqrstuvwxyz

Cipher Text : DEFGHIJKLMNOPQRSTUVWXYZABC

Encryption is done using the formula: C=Ek(P) mod 26

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.

The following is an example of Vernam Cipher implementation:

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:

W...E...C... R... L... T.... E


. E . R . D . S .O .. E . E . F . E . A . O . C .
..A... I... V... D... E.. . N..

Then read off to get the ciphertext:

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

2. They then compute their system modulus n=p*q, note ø(n)=(p-1)(q-1)


3. Then they select at random, the encryption key or private key e, where 1<e<ø(n),
gcd(e,ø(n))=1
4. Then solve following equation to find decryption key d , e.d=1 mod ø(n) and 0≤d≤n
5. The public key: PU={e,n} is published
6. The secret key is kept private : PR={d,n}
7. Encryption is done as : C= Me mod n
8. Decryption is done as : M=Cd mod n
5. USING OPENSSL COMMAND TO GENERATE PASSWORDS

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:

 Creation and management of private keys, public keys and parameters


 Public key cryptographic operations
 Creation of X.509 certificates, CSRs and CRLs
 Calculation of Message Digests
 Encryption and Decryption with Ciphers
 SSL/TLS Client and Server Tests
 Handling of S/MIME signed or encrypted mail
 Time Stamp requests, generation and verification
RSA Algorithm:
import java.util.*;
import java.lang.*;
import java.io.*;
class RSA
{
public static void main(String args[])
{
Scanner s=new Scanner(System.in);
int p,q,n,z,e,i,d=0;
System.out.println("Enter the number to be encrypted and decrypted");
int msg=s.nextInt();
double c,msgback;
System.out.println("Enetr 1st prime number p ");
p=s.nextInt();
System.out.println("Enter 2nd prime number q");
q=s.nextInt();
n=p*q;
z=(p-1)*(q-1);
System.out.println("the value of z="+z);
for(e=2;e<z;e++)
{
if(gcd(e,z)==1)
{
break;
}
}

System.out.println("the value of e="+e);


for(i=0;i<=9;i++)
{
int x=1+(i*z);
if(x%e==0)
{
d=x/e;
break;
}
}
System.out.println("the value of d="+d);
c=(Math.pow(msg,e))%n;
System.out.println("encrypted message is:_");
System.out.println(c);
msgback=(Math.pow(c,d))%n;
System.out.println("decrypted message is:_");
System.out.println(msgback);
}

static int gcd(int e,int z)


{
if(e==0)
return z;
else
{
return gcd(z%e,e);
}
}
}

You might also like