Crack Caesar Cipher Java Code

An example of the Caesar cipher is rot13 (rotate by 13 places) in which the alphabet is rotated by exactly the halve alphabet. A second encryption would result in the original string used by the first encryption. I had the idea to crack the encryption on base of an analysis of the quantity of every letter and to obtain the used key this way.

Active1 year, 5 months ago

i did caesar cipher code by java it runs but doesnt encrypt anything after user enter the key !

here is my code

run:

cricket_007
90.6k11 gold badges57 silver badges136 bronze badges
user5892270

3 Answers

Using indexOf is not very efficient... You can do integer arithmetic on char values to get their indices.

I included comments in the code to explain more, but this is what I came up with.

The output should be something like

cricket_007cricket_007
90.6k11 gold badges57 silver badges136 bronze badges

Try this:

Caesar Cipher Encryption Code Ltilkzljbypafpufvbykuh

This will work for all alphabetical strings... But as per your program, this will convert the original message to lowercase. So this is not pure encryption since your program is case insensitive.

Crack Caesar Cipher Java Code

If you want your program to be case sensitive, here is the program:

Hope this gives some idea. All the best.

Sunil ChakravarthySunil Chakravarthy

Caesar Cipher Java Program

This is probably the easiest way to do it and the most easy to understand:

Caesar Cipher Decryption Java

Stephen Rauch
33k15 gold badges44 silver badges69 bronze badges

Caesar Cipher Java Program

mandipmandip