-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcaesarController.java
More file actions
92 lines (62 loc) · 1.9 KB
/
Copy pathcaesarController.java
File metadata and controls
92 lines (62 loc) · 1.9 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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
import javafx.fxml.FXML;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.control.TextField;
import javafx.event.ActionEvent;
public class caesarController {
@FXML
private TextField inputTextField;
@FXML
private Button encryptButton;
@FXML
private Label titleLabel;
@FXML
private TextField outputTextField;
@FXML
private TextField inputTextField1;
@FXML
private TextField outputTextField1;
@FXML
private Button decryptButton;
@FXML
private TextField numberTextField;
public void initialize() {
}
@FXML
private void encryptText(ActionEvent e) {
//Get text from inputText Field
String number = numberTextField.getText();
try {
int n = Integer.valueOf(number);
//Ensure text is not empty
if (inputTextField.getText() != null && inputTextField.getText().length() != 0) {
//Pass text to Encryption Class
String message = inputTextField.getText();
Encrypt hidden = new Encrypt(message, n);
String output = hidden.encryptText();
//return encrypted text and print to outputTExtField
outputTextField.setText(output);
}
}
catch (Exception exception) {
numberTextField.setText("Enter valid number");
}
}
@FXML
void decryptText(ActionEvent event) {
//Get text from inputText Field
String number = numberTextField.getText();
try {
int n = Integer.parseInt(number);
if (inputTextField1.getText() != null && inputTextField1.getText().length() != 0) {
String message = inputTextField1.getText();
Decrypt hidden = new Decrypt(message, n);
String output = hidden.decryptText();
outputTextField1.setText(output);
}
}
catch (Exception exception) {
numberTextField.setText("Enter valid number");
}
}
}