2. This problem explores the use of a one-time pad version of the Vigenère ciphe
ID: 3724483 • Letter: 2
Question
2. This problem explores the use of a one-time pad version of the Vigenère cipher. In this scheme, the key is a stream of random numbers between U and 26. For example, if the key is 3 19 5..., then the first letter of plaintext is encrypted with a shift of 3 letters, the second with a shift of 19 letters, the third with a shift of 5 letters, and so on. a. Encrypt the plaintext sendmoremoney with the key stream 9 01 7 23 15 21 14 11 11 2 8 9 b. Using the ciphertext produced in part (a). find a key so that the cipher text decrypts to the plaintext cashnotneeded 3. Consider the following letter encodings: letter |A E I MOR T |V encoding 000 001 010 011 100 101110 111 A message M = MARIO is Vernain encrypted into ciphertext C AOAI/V: C' = Me. K. where shows modulo 2 XOR operation. Find corresponding encryption key. Provide details of your cryptanalaysis 4. DES Ilustration This problem provides a numerical example of encryption using a one-round ver- sion of DES 0123456789 A BCDEFExplanation / Answer
The answer to question a)
import java.io.*;
import java.lang.*;
public class Ciphertext {
public static void main(String[] args) throws IOException {
int c = 0, i = 0, e, d = 0;
int key[] = {9,0,1,7,23,15,21,14,11,11,2,8,9}; // Here key is the array said in the question
DataInputStream in = new DataInputStream(System.in);
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
char s[] = new char[20];
String S;
S="sendmoremoney"; // it is the plain text
System.out.println(" your text is: "+S);
i = 0;
s = S.toCharArray();
int L=S.length();
while (i<L) {
s[i] = (char) (s[i] + key[i]); // key is added to plaintext
d = s[i] / 26;
if (d == 0) {
continue;
}
else if (d > 0) {
e = s[i] % 26;
s[i] = (char) (e + 97);
}
i++;
}
String S1 = String.valueOf(s);
System.out.println(" your Cipher text is: " + S1);
}
}
}
Answer to question b)
The new string is cashnotneeded, so we need compute the difference between this new text and that difference will be the new key.
We do it like this,
String S2 = "cashnotneeded";
i=0;
while(i<L)
{
c[i] = S1.charAt(i) - S2.charAt(i);
if (c[i]<0)
c[i]= c[i]+26;
i++;
}
System.out.println("difference is = ");
for( i=0;i<L;i++)
{
System.out.print(c[i]+" ");
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.