-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathcsrBreaker.java
More file actions
40 lines (36 loc) · 802 Bytes
/
Copy pathcsrBreaker.java
File metadata and controls
40 lines (36 loc) · 802 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import java.util.Scanner;
public class csrBreaker{
public static void main(String[] args) {
Scanner s=new Scanner(System.in);
int choice=10;
String orgMsg="",modMsg="";
int k=0;
System.out.println("Message to be decrypted:");
orgMsg=s.nextLine();
while(k<27){
modMsg="";
int flag;
for(int i=0;i<orgMsg.length();++i){
if(Character.isUpperCase(orgMsg.charAt(i))){
flag=orgMsg.charAt(i)-k-65;
if(flag<0)
modMsg+=(char)(90+flag);
else
modMsg+=(char)(flag+65);
}
else if(Character.isLowerCase(orgMsg.charAt(i))){
flag=orgMsg.charAt(i)-k-97;
if(flag<0)
modMsg+=(char)(123+flag);
else
modMsg+=(char)(flag+97);
}
else{
modMsg+=orgMsg.charAt(i);
}
}
System.out.println("Trial "+k+" "+modMsg);
++k;
}
}
}