Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- printf("%c",M);
- import java.util.Scanner;
- public class DES {
- /**
- * @param args
- */
- public static void main(String[] args) {
- Scanner eingabe = new Scanner(System.in);
- int p, q, key2, fn, encryption_key, temp1 , temp2 ,
- t, s =0 , privatekey1=1, b=0 , passwort_s=0, klartext;
- int[] Cipher = new int [100];
- String passwort;
- System.out.println("Enter the value of p and q");
- p = eingabe.nextInt();
- q = eingabe.nextInt();
- System.out.println(p);
- System.out.println(q);
- key2= p*q;
- fn=(p-1)*(q-1);
- System.out.println("Enter Enryption key e: ");
- encryption_key = eingabe.nextInt();
- do {
- s=(privatekey1*encryption_key)%fn;
- privatekey1++;
- } while (s!=1);
- privatekey1=privatekey1-1;
- System.out.println("Public Key : "+ encryption_key + ","+ key2 );
- System.out.println("Private Key: "+ privatekey1 + "," +key2 );
- System.out.println("Enter Message: ");
- passwort= eingabe.next();
- for ( temp2 = 0; temp2 < passwort.length(); temp2++)
- {
- t = passwort.charAt(temp2);
- passwort_s=1;
- for(temp1 =0 ; temp1< encryption_key ; temp1++){
- passwort_s= passwort_s*t%key2;
- }
- passwort_s= passwort_s%key2;
- System.out.println(passwort_s);
- }
- System.out.println("Enter cipher Text: ");
- for(temp1=0;temp1< passwort.length(); temp1++ )
- {
- Cipher[temp1]= eingabe.nextInt();
- }
- System.out.println("Plainttext: ");
- for(temp2 =0; temp2 < passwort.length(); temp2++);
- {
- klartext=1;
- for(temp1 =0; temp1 < privatekey1; temp1 ++){
- klartext=klartext*Cipher[temp2]%key2;
- }
- klartext=klartext%key2;
- System.out.println(klartext);
- }
- }
- }
- printf("%c",M);
- int a = 70;
- char c = (char)a;
- System.out.print(a);
- output.print((char)M);
Add Comment
Please, Sign In to add comment