-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathText_encrypt.java
More file actions
73 lines (63 loc) · 2.43 KB
/
Text_encrypt.java
File metadata and controls
73 lines (63 loc) · 2.43 KB
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
package text_encrypt;
import java.util.Scanner;
public class Main{
public static void main(String[] args) {
int close = 0;
while (close < 1) {
System.out.println("Encrypt Program");
Scanner reader = new Scanner(System.in);
System.out.print("Enter Your Text: ");
String userInput = reader.nextLine();
reader = new Scanner(System.in);
System.out.print("Enter Your Seed: ");
int seed = reader.nextInt();
reader = new Scanner(System.in);
System.out.println("Type Y to Encrypt");
System.out.println("Type N to UnEncrypt");
System.out.println("Type EXIT to Close the Program");
System.out.print(">: ");
String enun = reader.nextLine();
enun = enun.toUpperCase();
System.out.println(enun);
String UperUserInput = userInput.toUpperCase();
int lenthOfInput = UperUserInput.length();
int place = 0;
String encry = (">");
String auf = "ABCDEFGHIJKLMNOPQRSTUVWXYZ ";
while (place < lenthOfInput) {
char letter = UperUserInput.charAt(place);
int NumberinAuf = auf.indexOf(letter);
if (NumberinAuf != -1) {
if (enun.equals("Y")) {
int AfterNumberinAuf = (NumberinAuf + seed) % auf.length();
if (AfterNumberinAuf < 0) {
AfterNumberinAuf = AfterNumberinAuf + 27;
}
char encryLetter = auf.charAt(AfterNumberinAuf);
String lencry = encry + encryLetter;
encry = lencry;
//System.out.println(encry);
}
if (enun.equals("N")) {
int AfterNumberinAuf = (NumberinAuf - seed) % auf.length();
if (AfterNumberinAuf < 0) {
AfterNumberinAuf = AfterNumberinAuf + 27;
}
char encryLetter = auf.charAt(AfterNumberinAuf);
String lencry = encry + encryLetter;
encry = lencry;
//System.out.println(encry);
}
if (enun.equals("EXIT")) {
close = 1;
}
}
place = place + 1;
}
System.out.println(UperUserInput);
System.out.println(encry);
System.out.print("\n");
}
}
}
//Made By Kai