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.
i did caesar cipher code by java it runs but doesnt encrypt anything after user enter the key !
here is my code
run:
cricket_0073 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_007Try 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.
If you want your program to be case sensitive, here is the program:
Hope this gives some idea. All the best.
Caesar Cipher Java Program
This is probably the easiest way to do it and the most easy to understand: