33public class Text_encrypt {
44 public static void main (String [] args ) {
55 System .out .println ("Encrypt Program" );
6- Scanner myObj = new Scanner (System .in );
6+
7+ Scanner reader = new Scanner (System .in );
78 System .out .print ("Enter Your Text: " );
8- String userInput = myObj .nextLine ();
9- int seed = 7 ;
9+ String userInput = reader .nextLine ();
10+
11+ reader = new Scanner (System .in );
12+ System .out .print ("Enter Your Seed: " );
13+ int seed = reader .nextInt ();
14+
15+ reader = new Scanner (System .in );
16+ System .out .println ("Type Y to Encrypt" );
17+ System .out .println ("Type N to UnEncrypt" );
18+ System .out .println ("Type EXIT to Close the Program" );
19+ System .out .print (">: " );
20+ String enun = reader .nextLine ();
21+ enun = enun .toUpperCase ();
22+ System .out .println (enun );
23+
24+
1025 String UperUserInput = userInput .toUpperCase ();
1126 int lenthOfInput = UperUserInput .length ();
1227 int place = 0 ;
@@ -18,11 +33,28 @@ public static void main(String[] args) {
1833
1934 int NumberinAuf = auf .indexOf (letter );
2035 if (NumberinAuf != -1 ) {
21- int AfterNumberinAuf = (NumberinAuf + seed ) % auf .length ();
22- char encryLetter = auf .charAt (AfterNumberinAuf );
23- String lencry = encry + encryLetter ;
24- encry = lencry ;
25- //System.out.println(encry);
36+ if (enun .equals ("Y" )) {
37+ int AfterNumberinAuf = (NumberinAuf + seed ) % auf .length ();
38+
39+ if (AfterNumberinAuf < 0 ) {
40+ AfterNumberinAuf = AfterNumberinAuf + 27 ;
41+ }
42+ char encryLetter = auf .charAt (AfterNumberinAuf );
43+ String lencry = encry + encryLetter ;
44+ encry = lencry ;
45+ //System.out.println(encry);
46+ }
47+ if (enun .equals ("N" )) {
48+ int AfterNumberinAuf = (NumberinAuf - seed ) % auf .length ();
49+
50+ if (AfterNumberinAuf < 0 ) {
51+ AfterNumberinAuf = AfterNumberinAuf + 27 ;
52+ }
53+ char encryLetter = auf .charAt (AfterNumberinAuf );
54+ String lencry = encry + encryLetter ;
55+ encry = lencry ;
56+ //System.out.println(encry);
57+ }
2658 }
2759
2860 place = place + 1 ;
0 commit comments