mini project of final year, Assignments of Software Project Management

assignment report on ini project of final year seventh semester

Typology: Assignments

2020/2021

Uploaded on 06/06/2021

jyoti-jadhav-1
jyoti-jadhav-1 🇮🇳

4

(2)

3 documents

1 / 12

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
ICS_Mini_Project | Group_ID_12
Group ID: - 12
Name of Team Members: -
Jadhav Jyoti Bandu
Walke Prajakta Vishnu
Waikar Shweta Vijay
Gawari Yogita Sayaji
Subject: - ICS (Mini Project)
Title: -
Mini Project on Playfair Cipher.
Problem Statement: -
Implement the Playfair Cipher technique on text which encrypt and decrypt the
test and display output.
Page | 1
pf3
pf4
pf5
pf8
pf9
pfa

Partial preview of the text

Download mini project of final year and more Assignments Software Project Management in PDF only on Docsity!

Group ID: - 12

Name of Team Members: -

Jadhav Jyoti Bandu

Walke Prajakta Vishnu

Waikar Shweta Vijay

Gawari Yogita Sayaji

Subject : - ICS (Mini Project)

Title: -

Mini Project on Playfair Cipher.

Problem Statement: -

Implement the Playfair Cipher technique on text which encrypt and decrypt the

test and display output.

Program Code: -

import java.awt.Point; import java.util.Scanner; public class PlayfairCipher { //length of digraph array private int length = 0; //creates a matrix for Playfair cipher private String [][] table; //main() method to test Playfair method public static void main(String args[]) { PlayfairCipher pf = new PlayfairCipher(); } //main run of the program, Playfair method //constructor of the class private PlayfairCipher() { //prompts user for the keyword to use for encoding & creates tables System.out.print("Enter the key for playfair cipher: "); Scanner sc = new Scanner(System.in); String key = parseString(sc); while(key.equals("")) key = parseString(sc);

parse = parse.replace("J", "I"); return parse; } //creates the cipher table based on some input string (already parsed) private String[][] cipherTable(String key) { //creates a matrix of 5* String[][] playfairTable = new String[5][5]; String keyString = key + "ABCDEFGHIKLMNOPQRSTUVWXYZ"; //fill string array with empty string for(int i = 0; i < 5; i++) for(int j = 0; j < 5; j++) playfairTable[i][j] = ""; for(int k = 0; k < keyString.length(); k++) { boolean repeat = false; boolean used = false; for(int i = 0; i < 5; i++) { for(int j = 0; j < 5; j++) { if(playfairTable[i][j].equals("" + keyString.charAt(k))) { repeat = true;

else if(playfairTable[i][j].equals("") && !repeat && !used) { playfairTable[i][j] = "" + keyString.charAt(k); used = true; } } } } return playfairTable; } //cipher: takes input (all upper-case), encodes it, and returns the output private String cipher(String in) { length = (int) in.length() / 2 + in.length() % 2; //insert x between double-letter digraphs & redefines "length" for(int i = 0; i < (length - 1); i++) { if(in.charAt(2 * i) == in.charAt(2 * i + 1)) { in = new StringBuffer(in).insert(2 * i + 1, 'X').toString(); length = (int) in.length() / 2 + in.length() % 2; }

String[] encipher = new String[length]; for(int i = 0; i < length; i++) { char a = di[i].charAt(0); char b = di[i].charAt(1); int r1 = (int) getPoint(a).getX(); int r2 = (int) getPoint(b).getX(); int c1 = (int) getPoint(a).getY(); int c2 = (int) getPoint(b).getY(); //executes if the letters of digraph appear in the same row //in such case shift columns to right if(r1 == r2) { c1 = (c1 + 1) % 5; c2 = (c2 + 1) % 5; } //executes if the letters of digraph appear in the same column //in such case shift rows down else if(c1 == c2) { r1 = (r1 + 1) % 5; r2 = (r2 + 1) % 5; }

//executes if the letters of digraph appear in the different row and different column //in such case swap the first column with the second column else { int temp = c1; c1 = c2; c2 = temp; } //performs the table look-up and puts those values into the encoded array encipher[i] = table[r1][c1] + "" + table[r2][c2]; } return encipher; } //-----------------------decryption logic--------------------- // decodes the output given from the cipher and decode methods (opp. of encoding process) private String decode(String out) { String decoded = ""; for(int i = 0; i < out.length() / 2; i++) { char a = out.charAt(2i); char b = out.charAt(2i+1); int r1 = (int) getPoint(a).getX(); int r2 = (int) getPoint(b).getX();

// returns a point containing the row and column of the letter private Point getPoint(char c) { Point pt = new Point(0,0); for(int i = 0; i < 5; i++) for(int j = 0; j < 5; j++) if(c == table[i][j].charAt(0)) pt = new Point(i,j); return pt; } //function prints the key-table in matrix form for playfair cipher private void keyTable(String[][] printTable) { System.out.println("Playfair Cipher Key Matrix: "); System.out.println(); //loop iterates for rows for(int i = 0; i < 5; i++) { //loop iterates for column for(int j = 0; j < 5; j++) { //prints the key-table in matrix form System.out.print(printTable[i][j]+" "); }

System.out.println(); } System.out.println(); } //method that prints all the results private void printResults(String encipher, String dec) { System.out.print("Encrypted Message: "); //prints the encrypted message System.out.println(encipher); System.out.println(); System.out.print("Decrypted Message: "); //prints the decryted message System.out.println(dec); } }