Implement Caesar Cipher in Java?

0 Comments

In cryptography, a Caesar cipher, also known as Caesar’s cipher, the shift cipher, Caesar’s code or Caesar shift, is one of the simplest and most widely known encryption techniques.

Lets implement this;

//First we take input of word

Scanner input = new Scanner (System.in);

System.out.println("Enter Word");

String word=input.nextLine();

//Then we take input for steps  or we can say that how many steps we have to shift

System.out.println("Enter Steps");

int steps=input.nextInt();

for (int i=0;i<word.length();i++)

{

char alphabet=word.charAt(i);

int x= (int)(alphabet)+3;

System.out.println((char)x);

}


Leave a Reply

Your email address will not be published.