SlideShare a Scribd company logo
1 of 3
Download to read offline
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
public class CbcVigenere {
public static void main(String[] args) throws IOException {
File f= new File(args[0]);
BufferedReader bufferedReader = new BufferedReader(new FileReader(f));
StringBuffer stringBuffer = new StringBuffer();
String line;
while((line =bufferedReader.readLine())!=null){
stringBuffer.append(line).append(" ");
}
String input = stringBuffer.toString();
String extract = input.replaceAll("[^a-zA-Z]+", "").toLowerCase();
int k = extract.length();
String plaintxt = extract.replaceAll("(.{80})","$1 ");
System.out.println("Plaintext file name: " + args[0]);
System.out.println("Vigenere keyword: " + args[1]);
System.out.println("Initialization vector: " + args[2]+ " ");
System.out.println("Clean Plaintext:  " + plaintxt + " ");
int pad=0;
do {
extract= extract + "x";
pad++;
}while(extract.length() % args[1].length() != 0);
int j=0;
String fullcipher= "";
for( int i=0;i<(extract.length()/ args[1].length());i++){
String ciphertxt = encrypt(extract, args[1], args[2], j );
j=j + args[1].length();
args[2] = ciphertxt;
fullcipher = fullcipher + ciphertxt;
}
//System.out.println(plaintxt.length()/args[1].length());
System.out.println("Ciphertext:  " + fullcipher.replaceAll("(.{80})","$1 "));
System.out.println(" Number of characters in clean plaintext file: " + k);
System.out.println("Block size = " + args[1].length());
System.out.println("Number is pad characters added: " + pad);
}
public static String encrypt(String txt, String key, String IV, int pos){
String ab ="";
String cd ="";
for(int i=0; i
Solution
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
public class CbcVigenere {
public static void main(String[] args) throws IOException {
File f= new File(args[0]);
BufferedReader bufferedReader = new BufferedReader(new FileReader(f));
StringBuffer stringBuffer = new StringBuffer();
String line;
while((line =bufferedReader.readLine())!=null){
stringBuffer.append(line).append(" ");
}
String input = stringBuffer.toString();
String extract = input.replaceAll("[^a-zA-Z]+", "").toLowerCase();
int k = extract.length();
String plaintxt = extract.replaceAll("(.{80})","$1 ");
System.out.println("Plaintext file name: " + args[0]);
System.out.println("Vigenere keyword: " + args[1]);
System.out.println("Initialization vector: " + args[2]+ " ");
System.out.println("Clean Plaintext:  " + plaintxt + " ");
int pad=0;
do {
extract= extract + "x";
pad++;
}while(extract.length() % args[1].length() != 0);
int j=0;
String fullcipher= "";
for( int i=0;i<(extract.length()/ args[1].length());i++){
String ciphertxt = encrypt(extract, args[1], args[2], j );
j=j + args[1].length();
args[2] = ciphertxt;
fullcipher = fullcipher + ciphertxt;
}
//System.out.println(plaintxt.length()/args[1].length());
System.out.println("Ciphertext:  " + fullcipher.replaceAll("(.{80})","$1 "));
System.out.println(" Number of characters in clean plaintext file: " + k);
System.out.println("Block size = " + args[1].length());
System.out.println("Number is pad characters added: " + pad);
}
public static String encrypt(String txt, String key, String IV, int pos){
String ab ="";
String cd ="";
for(int i=0; i

More Related Content

Similar to import java.io.BufferedReader; import java.io.File; import java..pdf

import java.io.BufferedReader; import java.io.IOException; impor.pdf
import java.io.BufferedReader; import java.io.IOException; impor.pdfimport java.io.BufferedReader; import java.io.IOException; impor.pdf
import java.io.BufferedReader; import java.io.IOException; impor.pdfaravlitraders2012
 
Please help me with a UML class diagram for the following code im.pdf
Please help me with a UML class diagram for the following code im.pdfPlease help me with a UML class diagram for the following code im.pdf
Please help me with a UML class diagram for the following code im.pdfaioils
 
A topology of memory leaks on the JVM
A topology of memory leaks on the JVMA topology of memory leaks on the JVM
A topology of memory leaks on the JVMRafael Winterhalter
 
Create a text file named lnfo.txt. Enter the following informatio.pdf
Create a text file named lnfo.txt. Enter the following informatio.pdfCreate a text file named lnfo.txt. Enter the following informatio.pdf
Create a text file named lnfo.txt. Enter the following informatio.pdfshahidqamar17
 
Java programming lab_manual_by_rohit_jaiswar
Java programming lab_manual_by_rohit_jaiswarJava programming lab_manual_by_rohit_jaiswar
Java programming lab_manual_by_rohit_jaiswarROHIT JAISWAR
 
Write a program that will count the number of characters- words- and l.docx
Write a program that will count the number of characters- words- and l.docxWrite a program that will count the number of characters- words- and l.docx
Write a program that will count the number of characters- words- and l.docxlez31palka
 
Java IO Streams V4
Java IO Streams V4Java IO Streams V4
Java IO Streams V4Sunil OS
 
DisplayBook.java import java.io.File; import java.io.FileInput.pdf
DisplayBook.java import java.io.File; import java.io.FileInput.pdfDisplayBook.java import java.io.File; import java.io.FileInput.pdf
DisplayBook.java import java.io.File; import java.io.FileInput.pdfsudheerforce
 
Java căn bản - Chapter12
Java căn bản - Chapter12Java căn bản - Chapter12
Java căn bản - Chapter12Vince Vo
 
Chapter 12 - File Input and Output
Chapter 12 - File Input and OutputChapter 12 - File Input and Output
Chapter 12 - File Input and OutputEduardo Bergavera
 
• GUI design using drag and drop feature of IDE(Net beans), • File IO
•	GUI design using drag and drop feature of IDE(Net beans), •	File IO•	GUI design using drag and drop feature of IDE(Net beans), •	File IO
• GUI design using drag and drop feature of IDE(Net beans), • File IOSyedShahroseSohail
 
Object oriented programming la bmanual jntu
Object oriented programming la bmanual jntuObject oriented programming la bmanual jntu
Object oriented programming la bmanual jntuKhurshid Asghar
 
The Java Program for the above given isimport java.io.File;impo.pdf
The Java Program for the above given isimport java.io.File;impo.pdfThe Java Program for the above given isimport java.io.File;impo.pdf
The Java Program for the above given isimport java.io.File;impo.pdfanjanacottonmills
 

Similar to import java.io.BufferedReader; import java.io.File; import java..pdf (20)

Inheritance
InheritanceInheritance
Inheritance
 
import java.io.BufferedReader; import java.io.IOException; impor.pdf
import java.io.BufferedReader; import java.io.IOException; impor.pdfimport java.io.BufferedReader; import java.io.IOException; impor.pdf
import java.io.BufferedReader; import java.io.IOException; impor.pdf
 
Java Programming - 06 java file io
Java Programming - 06 java file ioJava Programming - 06 java file io
Java Programming - 06 java file io
 
Lab4
Lab4Lab4
Lab4
 
CORE JAVA-1
CORE JAVA-1CORE JAVA-1
CORE JAVA-1
 
Please help me with a UML class diagram for the following code im.pdf
Please help me with a UML class diagram for the following code im.pdfPlease help me with a UML class diagram for the following code im.pdf
Please help me with a UML class diagram for the following code im.pdf
 
Java I/o streams
Java I/o streamsJava I/o streams
Java I/o streams
 
A topology of memory leaks on the JVM
A topology of memory leaks on the JVMA topology of memory leaks on the JVM
A topology of memory leaks on the JVM
 
Create a text file named lnfo.txt. Enter the following informatio.pdf
Create a text file named lnfo.txt. Enter the following informatio.pdfCreate a text file named lnfo.txt. Enter the following informatio.pdf
Create a text file named lnfo.txt. Enter the following informatio.pdf
 
Java programming lab_manual_by_rohit_jaiswar
Java programming lab_manual_by_rohit_jaiswarJava programming lab_manual_by_rohit_jaiswar
Java programming lab_manual_by_rohit_jaiswar
 
Studyx5
Studyx5Studyx5
Studyx5
 
Write a program that will count the number of characters- words- and l.docx
Write a program that will count the number of characters- words- and l.docxWrite a program that will count the number of characters- words- and l.docx
Write a program that will count the number of characters- words- and l.docx
 
Java IO Streams V4
Java IO Streams V4Java IO Streams V4
Java IO Streams V4
 
Java Day-6
Java Day-6Java Day-6
Java Day-6
 
DisplayBook.java import java.io.File; import java.io.FileInput.pdf
DisplayBook.java import java.io.File; import java.io.FileInput.pdfDisplayBook.java import java.io.File; import java.io.FileInput.pdf
DisplayBook.java import java.io.File; import java.io.FileInput.pdf
 
Java căn bản - Chapter12
Java căn bản - Chapter12Java căn bản - Chapter12
Java căn bản - Chapter12
 
Chapter 12 - File Input and Output
Chapter 12 - File Input and OutputChapter 12 - File Input and Output
Chapter 12 - File Input and Output
 
• GUI design using drag and drop feature of IDE(Net beans), • File IO
•	GUI design using drag and drop feature of IDE(Net beans), •	File IO•	GUI design using drag and drop feature of IDE(Net beans), •	File IO
• GUI design using drag and drop feature of IDE(Net beans), • File IO
 
Object oriented programming la bmanual jntu
Object oriented programming la bmanual jntuObject oriented programming la bmanual jntu
Object oriented programming la bmanual jntu
 
The Java Program for the above given isimport java.io.File;impo.pdf
The Java Program for the above given isimport java.io.File;impo.pdfThe Java Program for the above given isimport java.io.File;impo.pdf
The Java Program for the above given isimport java.io.File;impo.pdf
 

More from aquacosmossystems

DnaAORC This protein is responsible for initiation of DNA replicat.pdf
DnaAORC This protein is responsible for initiation of DNA replicat.pdfDnaAORC This protein is responsible for initiation of DNA replicat.pdf
DnaAORC This protein is responsible for initiation of DNA replicat.pdfaquacosmossystems
 
Answer(19)Mary’s parents are normal, therefore her brother must.pdf
Answer(19)Mary’s parents are normal, therefore her brother must.pdfAnswer(19)Mary’s parents are normal, therefore her brother must.pdf
Answer(19)Mary’s parents are normal, therefore her brother must.pdfaquacosmossystems
 
Answer Q1. Red mangroove is the last mangroove to colonise on the.pdf
Answer Q1. Red mangroove is the last mangroove to colonise on the.pdfAnswer Q1. Red mangroove is the last mangroove to colonise on the.pdf
Answer Q1. Red mangroove is the last mangroove to colonise on the.pdfaquacosmossystems
 
An Arrhenius acid produces H+ ions insolutionA Bronsted-Lowry acid.pdf
An Arrhenius acid produces H+ ions insolutionA Bronsted-Lowry acid.pdfAn Arrhenius acid produces H+ ions insolutionA Bronsted-Lowry acid.pdf
An Arrhenius acid produces H+ ions insolutionA Bronsted-Lowry acid.pdfaquacosmossystems
 
Ans. One of the main disadvantage is chromatic aberrasion. A more li.pdf
Ans. One of the main disadvantage is chromatic aberrasion. A more li.pdfAns. One of the main disadvantage is chromatic aberrasion. A more li.pdf
Ans. One of the main disadvantage is chromatic aberrasion. A more li.pdfaquacosmossystems
 
A coordination problem occurs in situations where there is no Nash E.pdf
A coordination problem occurs in situations where there is no Nash E.pdfA coordination problem occurs in situations where there is no Nash E.pdf
A coordination problem occurs in situations where there is no Nash E.pdfaquacosmossystems
 
1. When an integrated F plasmid leaves the chromosome it may take so.pdf
1. When an integrated F plasmid leaves the chromosome it may take so.pdf1. When an integrated F plasmid leaves the chromosome it may take so.pdf
1. When an integrated F plasmid leaves the chromosome it may take so.pdfaquacosmossystems
 
1. A DNA molecule contains two strands of poly deoxyribonucleotide s.pdf
1. A DNA molecule contains two strands of poly deoxyribonucleotide s.pdf1. A DNA molecule contains two strands of poly deoxyribonucleotide s.pdf
1. A DNA molecule contains two strands of poly deoxyribonucleotide s.pdfaquacosmossystems
 
Ethyl 4-aminobenzoate is a basic organic compound. In basic and neut.pdf
  Ethyl 4-aminobenzoate is a basic organic compound. In basic and neut.pdf  Ethyl 4-aminobenzoate is a basic organic compound. In basic and neut.pdf
Ethyl 4-aminobenzoate is a basic organic compound. In basic and neut.pdfaquacosmossystems
 
draw a sphere and use raytracing on the sphere in OpenGL glut. .pdf
 draw a sphere and use raytracing on the sphere in OpenGL glut. .pdf draw a sphere and use raytracing on the sphere in OpenGL glut. .pdf
draw a sphere and use raytracing on the sphere in OpenGL glut. .pdfaquacosmossystems
 
SnO2 (ore) is initially washed and dressed. then .pdf
                     SnO2 (ore) is initially washed and dressed. then .pdf                     SnO2 (ore) is initially washed and dressed. then .pdf
SnO2 (ore) is initially washed and dressed. then .pdfaquacosmossystems
 
d) Valine Note its side chain doesnt contain a.pdf
                     d) Valine Note its side chain doesnt contain a.pdf                     d) Valine Note its side chain doesnt contain a.pdf
d) Valine Note its side chain doesnt contain a.pdfaquacosmossystems
 
Amphiprotic. The preferred term is amphoteric. A .pdf
                     Amphiprotic. The preferred term is amphoteric. A .pdf                     Amphiprotic. The preferred term is amphoteric. A .pdf
Amphiprotic. The preferred term is amphoteric. A .pdfaquacosmossystems
 
at equivalence point, Moles OH- added = moles H+.pdf
                     at equivalence point,  Moles OH- added = moles H+.pdf                     at equivalence point,  Moles OH- added = moles H+.pdf
at equivalence point, Moles OH- added = moles H+.pdfaquacosmossystems
 
We Know that     Water is a Polar component as .pdf
                     We Know that      Water is a Polar component as .pdf                     We Know that      Water is a Polar component as .pdf
We Know that     Water is a Polar component as .pdfaquacosmossystems
 
molar mass of C2H5OH = 46.1 gmole moles of C2H5O.pdf
                     molar mass of C2H5OH = 46.1 gmole moles of C2H5O.pdf                     molar mass of C2H5OH = 46.1 gmole moles of C2H5O.pdf
molar mass of C2H5OH = 46.1 gmole moles of C2H5O.pdfaquacosmossystems
 
What property of PN code makes them suitable for use in spread spect.pdf
What property of PN code makes them suitable for use in spread spect.pdfWhat property of PN code makes them suitable for use in spread spect.pdf
What property of PN code makes them suitable for use in spread spect.pdfaquacosmossystems
 
TLC can be used to help determine the number of components in a mixt.pdf
TLC can be used to help determine the number of components in a mixt.pdfTLC can be used to help determine the number of components in a mixt.pdf
TLC can be used to help determine the number of components in a mixt.pdfaquacosmossystems
 
There may have some variables affect the model. So the error term wi.pdf
There may have some variables affect the model. So the error term wi.pdfThere may have some variables affect the model. So the error term wi.pdf
There may have some variables affect the model. So the error term wi.pdfaquacosmossystems
 
There are four major functional characteristics of skeletal muscle..pdf
There are four major functional characteristics of skeletal muscle..pdfThere are four major functional characteristics of skeletal muscle..pdf
There are four major functional characteristics of skeletal muscle..pdfaquacosmossystems
 

More from aquacosmossystems (20)

DnaAORC This protein is responsible for initiation of DNA replicat.pdf
DnaAORC This protein is responsible for initiation of DNA replicat.pdfDnaAORC This protein is responsible for initiation of DNA replicat.pdf
DnaAORC This protein is responsible for initiation of DNA replicat.pdf
 
Answer(19)Mary’s parents are normal, therefore her brother must.pdf
Answer(19)Mary’s parents are normal, therefore her brother must.pdfAnswer(19)Mary’s parents are normal, therefore her brother must.pdf
Answer(19)Mary’s parents are normal, therefore her brother must.pdf
 
Answer Q1. Red mangroove is the last mangroove to colonise on the.pdf
Answer Q1. Red mangroove is the last mangroove to colonise on the.pdfAnswer Q1. Red mangroove is the last mangroove to colonise on the.pdf
Answer Q1. Red mangroove is the last mangroove to colonise on the.pdf
 
An Arrhenius acid produces H+ ions insolutionA Bronsted-Lowry acid.pdf
An Arrhenius acid produces H+ ions insolutionA Bronsted-Lowry acid.pdfAn Arrhenius acid produces H+ ions insolutionA Bronsted-Lowry acid.pdf
An Arrhenius acid produces H+ ions insolutionA Bronsted-Lowry acid.pdf
 
Ans. One of the main disadvantage is chromatic aberrasion. A more li.pdf
Ans. One of the main disadvantage is chromatic aberrasion. A more li.pdfAns. One of the main disadvantage is chromatic aberrasion. A more li.pdf
Ans. One of the main disadvantage is chromatic aberrasion. A more li.pdf
 
A coordination problem occurs in situations where there is no Nash E.pdf
A coordination problem occurs in situations where there is no Nash E.pdfA coordination problem occurs in situations where there is no Nash E.pdf
A coordination problem occurs in situations where there is no Nash E.pdf
 
1. When an integrated F plasmid leaves the chromosome it may take so.pdf
1. When an integrated F plasmid leaves the chromosome it may take so.pdf1. When an integrated F plasmid leaves the chromosome it may take so.pdf
1. When an integrated F plasmid leaves the chromosome it may take so.pdf
 
1. A DNA molecule contains two strands of poly deoxyribonucleotide s.pdf
1. A DNA molecule contains two strands of poly deoxyribonucleotide s.pdf1. A DNA molecule contains two strands of poly deoxyribonucleotide s.pdf
1. A DNA molecule contains two strands of poly deoxyribonucleotide s.pdf
 
Ethyl 4-aminobenzoate is a basic organic compound. In basic and neut.pdf
  Ethyl 4-aminobenzoate is a basic organic compound. In basic and neut.pdf  Ethyl 4-aminobenzoate is a basic organic compound. In basic and neut.pdf
Ethyl 4-aminobenzoate is a basic organic compound. In basic and neut.pdf
 
draw a sphere and use raytracing on the sphere in OpenGL glut. .pdf
 draw a sphere and use raytracing on the sphere in OpenGL glut. .pdf draw a sphere and use raytracing on the sphere in OpenGL glut. .pdf
draw a sphere and use raytracing on the sphere in OpenGL glut. .pdf
 
SnO2 (ore) is initially washed and dressed. then .pdf
                     SnO2 (ore) is initially washed and dressed. then .pdf                     SnO2 (ore) is initially washed and dressed. then .pdf
SnO2 (ore) is initially washed and dressed. then .pdf
 
d) Valine Note its side chain doesnt contain a.pdf
                     d) Valine Note its side chain doesnt contain a.pdf                     d) Valine Note its side chain doesnt contain a.pdf
d) Valine Note its side chain doesnt contain a.pdf
 
Amphiprotic. The preferred term is amphoteric. A .pdf
                     Amphiprotic. The preferred term is amphoteric. A .pdf                     Amphiprotic. The preferred term is amphoteric. A .pdf
Amphiprotic. The preferred term is amphoteric. A .pdf
 
at equivalence point, Moles OH- added = moles H+.pdf
                     at equivalence point,  Moles OH- added = moles H+.pdf                     at equivalence point,  Moles OH- added = moles H+.pdf
at equivalence point, Moles OH- added = moles H+.pdf
 
We Know that     Water is a Polar component as .pdf
                     We Know that      Water is a Polar component as .pdf                     We Know that      Water is a Polar component as .pdf
We Know that     Water is a Polar component as .pdf
 
molar mass of C2H5OH = 46.1 gmole moles of C2H5O.pdf
                     molar mass of C2H5OH = 46.1 gmole moles of C2H5O.pdf                     molar mass of C2H5OH = 46.1 gmole moles of C2H5O.pdf
molar mass of C2H5OH = 46.1 gmole moles of C2H5O.pdf
 
What property of PN code makes them suitable for use in spread spect.pdf
What property of PN code makes them suitable for use in spread spect.pdfWhat property of PN code makes them suitable for use in spread spect.pdf
What property of PN code makes them suitable for use in spread spect.pdf
 
TLC can be used to help determine the number of components in a mixt.pdf
TLC can be used to help determine the number of components in a mixt.pdfTLC can be used to help determine the number of components in a mixt.pdf
TLC can be used to help determine the number of components in a mixt.pdf
 
There may have some variables affect the model. So the error term wi.pdf
There may have some variables affect the model. So the error term wi.pdfThere may have some variables affect the model. So the error term wi.pdf
There may have some variables affect the model. So the error term wi.pdf
 
There are four major functional characteristics of skeletal muscle..pdf
There are four major functional characteristics of skeletal muscle..pdfThere are four major functional characteristics of skeletal muscle..pdf
There are four major functional characteristics of skeletal muscle..pdf
 

Recently uploaded

Interdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptxInterdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptxPooja Bhuva
 
Basic Intentional Injuries Health Education
Basic Intentional Injuries Health EducationBasic Intentional Injuries Health Education
Basic Intentional Injuries Health EducationNeilDeclaro1
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxDenish Jangid
 
Wellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxWellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxJisc
 
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxHMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxmarlenawright1
 
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptxExploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptxPooja Bhuva
 
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxCOMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxannathomasp01
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.christianmathematics
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxJisc
 
How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17Celine George
 
Details on CBSE Compartment Exam.pptx1111
Details on CBSE Compartment Exam.pptx1111Details on CBSE Compartment Exam.pptx1111
Details on CBSE Compartment Exam.pptx1111GangaMaiya1
 
21st_Century_Skills_Framework_Final_Presentation_2.pptx
21st_Century_Skills_Framework_Final_Presentation_2.pptx21st_Century_Skills_Framework_Final_Presentation_2.pptx
21st_Century_Skills_Framework_Final_Presentation_2.pptxJoelynRubio1
 
Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPSSpellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPSAnaAcapella
 
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...Nguyen Thanh Tu Collection
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentationcamerronhm
 
latest AZ-104 Exam Questions and Answers
latest AZ-104 Exam Questions and Answerslatest AZ-104 Exam Questions and Answers
latest AZ-104 Exam Questions and Answersdalebeck957
 
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...Pooja Bhuva
 
dusjagr & nano talk on open tools for agriculture research and learning
dusjagr & nano talk on open tools for agriculture research and learningdusjagr & nano talk on open tools for agriculture research and learning
dusjagr & nano talk on open tools for agriculture research and learningMarc Dusseiller Dusjagr
 
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdfFICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdfPondicherry University
 

Recently uploaded (20)

Interdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptxInterdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptx
 
Basic Intentional Injuries Health Education
Basic Intentional Injuries Health EducationBasic Intentional Injuries Health Education
Basic Intentional Injuries Health Education
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
Wellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxWellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptx
 
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxHMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
 
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptxExploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
 
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxCOMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptx
 
How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17
 
Details on CBSE Compartment Exam.pptx1111
Details on CBSE Compartment Exam.pptx1111Details on CBSE Compartment Exam.pptx1111
Details on CBSE Compartment Exam.pptx1111
 
21st_Century_Skills_Framework_Final_Presentation_2.pptx
21st_Century_Skills_Framework_Final_Presentation_2.pptx21st_Century_Skills_Framework_Final_Presentation_2.pptx
21st_Century_Skills_Framework_Final_Presentation_2.pptx
 
Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPSSpellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
 
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentation
 
latest AZ-104 Exam Questions and Answers
latest AZ-104 Exam Questions and Answerslatest AZ-104 Exam Questions and Answers
latest AZ-104 Exam Questions and Answers
 
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
 
dusjagr & nano talk on open tools for agriculture research and learning
dusjagr & nano talk on open tools for agriculture research and learningdusjagr & nano talk on open tools for agriculture research and learning
dusjagr & nano talk on open tools for agriculture research and learning
 
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdfFICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
 

import java.io.BufferedReader; import java.io.File; import java..pdf

  • 1. import java.io.BufferedReader; import java.io.File; import java.io.FileReader; import java.io.IOException; public class CbcVigenere { public static void main(String[] args) throws IOException { File f= new File(args[0]); BufferedReader bufferedReader = new BufferedReader(new FileReader(f)); StringBuffer stringBuffer = new StringBuffer(); String line; while((line =bufferedReader.readLine())!=null){ stringBuffer.append(line).append(" "); } String input = stringBuffer.toString(); String extract = input.replaceAll("[^a-zA-Z]+", "").toLowerCase(); int k = extract.length(); String plaintxt = extract.replaceAll("(.{80})","$1 "); System.out.println("Plaintext file name: " + args[0]); System.out.println("Vigenere keyword: " + args[1]); System.out.println("Initialization vector: " + args[2]+ " "); System.out.println("Clean Plaintext: " + plaintxt + " "); int pad=0; do { extract= extract + "x"; pad++; }while(extract.length() % args[1].length() != 0); int j=0; String fullcipher= ""; for( int i=0;i<(extract.length()/ args[1].length());i++){ String ciphertxt = encrypt(extract, args[1], args[2], j ); j=j + args[1].length();
  • 2. args[2] = ciphertxt; fullcipher = fullcipher + ciphertxt; } //System.out.println(plaintxt.length()/args[1].length()); System.out.println("Ciphertext: " + fullcipher.replaceAll("(.{80})","$1 ")); System.out.println(" Number of characters in clean plaintext file: " + k); System.out.println("Block size = " + args[1].length()); System.out.println("Number is pad characters added: " + pad); } public static String encrypt(String txt, String key, String IV, int pos){ String ab =""; String cd =""; for(int i=0; i Solution import java.io.BufferedReader; import java.io.File; import java.io.FileReader; import java.io.IOException; public class CbcVigenere { public static void main(String[] args) throws IOException { File f= new File(args[0]); BufferedReader bufferedReader = new BufferedReader(new FileReader(f)); StringBuffer stringBuffer = new StringBuffer(); String line; while((line =bufferedReader.readLine())!=null){ stringBuffer.append(line).append(" "); } String input = stringBuffer.toString(); String extract = input.replaceAll("[^a-zA-Z]+", "").toLowerCase(); int k = extract.length(); String plaintxt = extract.replaceAll("(.{80})","$1 ");
  • 3. System.out.println("Plaintext file name: " + args[0]); System.out.println("Vigenere keyword: " + args[1]); System.out.println("Initialization vector: " + args[2]+ " "); System.out.println("Clean Plaintext: " + plaintxt + " "); int pad=0; do { extract= extract + "x"; pad++; }while(extract.length() % args[1].length() != 0); int j=0; String fullcipher= ""; for( int i=0;i<(extract.length()/ args[1].length());i++){ String ciphertxt = encrypt(extract, args[1], args[2], j ); j=j + args[1].length(); args[2] = ciphertxt; fullcipher = fullcipher + ciphertxt; } //System.out.println(plaintxt.length()/args[1].length()); System.out.println("Ciphertext: " + fullcipher.replaceAll("(.{80})","$1 ")); System.out.println(" Number of characters in clean plaintext file: " + k); System.out.println("Block size = " + args[1].length()); System.out.println("Number is pad characters added: " + pad); } public static String encrypt(String txt, String key, String IV, int pos){ String ab =""; String cd =""; for(int i=0; i