Java Programming for Caesor Chiper(Decryption)
import java.util.Scanner;
public class FirstClass {
public static void main(String[] args) {
String Ciphertext = "FHMDZY";
System.out.println("before decryption:"+Ciphertext);
Scanner input = new Scanner(System.in);
System.out.println("enter the key:");
int key = input.nextInt();
System.out.print("After decryption:");
for (int i = 0 ;i < Ciphertext.length() ;i++)
{
int integervalue = (int)Ciphertext.charAt(i);
int position = integervalue - 65;
int temp = (position + 26 - key)%26;
int backposition = temp + 65;
System.out.print((char)backposition);
}
}
}
OUTPUT
Post a Comment