Question: I need decryption this code public static String caesarCipher ( String text ) { String encryptedText = new String ( ) ; / / encrypted

I need decryption this code
public static String caesarCipher(String text){
String encryptedText = new String(); // encrypted text value
int key =3; // fixed Key value
for (int i =0; i < text.length(); i++){// Loop to check each character in the plaintext
char currentChar = text.charAt(i);
if (Character.isLetter(currentChar)){// Check if the character is a letter
char base =(char)((currentChar >='a')?'a' : 'A');// Encrypt by shifting each letter 3 times
char encryptedChar =(char)((currentChar - base + key)%26+ base);
encryptedText +=(encryptedChar);
} else {
encryptedText +=(currentChar);// non-letter characters unchanged
}
}
return encryptedText;
}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!