Skip to content

Commit

Permalink
version2
Browse files Browse the repository at this point in the history
  • Loading branch information
themasterz854 committed Nov 27, 2022
1 parent 5ccc981 commit 7eb8f42
Show file tree
Hide file tree
Showing 25 changed files with 243 additions and 245 deletions.
Binary file modified out/production/JAVAFX-SECRET-MESSAGING-APP/sample/AES.class
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified out/production/JAVAFX-SECRET-MESSAGING-APP/sample/Main.class
Binary file not shown.
17 changes: 10 additions & 7 deletions out/production/JAVAFX-SECRET-MESSAGING-APP/sample/decryption.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,21 @@
<?import javafx.scene.control.TextArea?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.text.Font?>

<AnchorPane prefHeight="400.0" prefWidth="600.0" styleClass="decryptionbg" stylesheets="@design.css" xmlns="http://javafx.com/javafx/16" xmlns:fx="http://javafx.com/fxml/1" fx:controller="sample.DecryptionController">
<children>
<TextArea fx:id="ta" layoutX="30.0" layoutY="74.0" opacity="0.6" prefHeight="274.0" prefWidth="249.0" text="&#10;" wrapText="true">
<TextArea fx:id="ta" layoutX="30.0" layoutY="74.0" opacity="0.6" prefHeight="274.0" prefWidth="249.0" text=""
wrapText="true">
<font>
<Font name="System Bold" size="15.0" />
</font></TextArea>
<Font name="System Bold" size="15.0"/>
</font>
</TextArea>
<Label layoutX="48.0" layoutY="34.0" text="Enter yout text here" />
<Button defaultButton="true" layoutX="259.0" layoutY="361.0" mnemonicParsing="false" onAction="#decryptrequest" text="DECRYPT" />
<TextArea fx:id="ota" editable="false" layoutX="330.0" layoutY="72.0" opacity="0.6" prefHeight="274.0" prefWidth="259.0" text="&#10;" wrapText="true">
<TextArea fx:id="ota" editable="false" layoutX="330.0" layoutY="72.0" opacity="0.6" prefHeight="274.0"
prefWidth="259.0" text="" wrapText="true">
<font>
<Font name="System Bold" size="15.0" />
</font></TextArea>
<Font name="System Bold" size="15.0"/>
</font>
</TextArea>
</children>
</AnchorPane>
20 changes: 9 additions & 11 deletions src/sample/AppController.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,16 @@

import static sample.Main.aes;

public class AppController extends Controller{
public class AppController extends Controller {
@FXML
private Label welcome;

public void transferdata(Socket s,String username){
public void transferdata(Socket s, String username) {
this.s = s;
welcome.setText("WELCOME "+username);
welcome.setText("WELCOME " + username);
}
public void get_list(){

public void get_list() {
try {
dout = new DataOutputStream(s.getOutputStream());
Stage client_list = new Stage();
Expand All @@ -33,14 +34,13 @@ public void get_list(){
dout.writeUTF(aes.encrypt("%list%"));
client_list.setResizable(false);
client_list.show();
}
catch (Exception e)
{
} catch (Exception e) {
e.printStackTrace();
System.exit(0);
}
}
public void decryptservice(){

public void decryptservice() {
try {
Stage decryptstage = new Stage();
FXMLLoader loader = new FXMLLoader(getClass().getResource("decryption.fxml"));
Expand All @@ -53,9 +53,7 @@ public void decryptservice(){
decryptstage.setResizable(false);
decryptstage.setTitle("Decryption Service");
decryptstage.show();
}
catch(Exception e)
{
} catch (Exception e) {
e.printStackTrace();
System.exit(0);
}
Expand Down
67 changes: 30 additions & 37 deletions src/sample/ChatDialogController.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,42 +19,43 @@
import static sample.Main.aes;


public class ChatDialogController extends Controller{
public class ChatDialogController extends Controller {
@FXML
private AnchorPane ap;
@FXML
private Button send_file_button,dirchoose;
private final String[] queue = new String[10];
@FXML
private TextField message;
@FXML
private TextArea ta,myta;
private Button send_file_button, dirchoose;
@FXML
private ToggleButton togglebutton;
@FXML
private Label encryplabel;
private int id;
private final String[] queue= new String[10];
@FXML
private TextArea ta, myta;
private boolean encryptflag = false;
private File directory;
private final DirectoryChooser dc = new DirectoryChooser();
public void transferdata(int cid, Socket s){

public void transferdata(int cid, Socket s) {
id = cid;
this.s = s;
}

public void direchooser()
{
public void direchooser() {
directory = dc.showDialog(null);
}
public synchronized void checkandwrite() throws Exception{

int front,rear;
public synchronized void checkandwrite() throws Exception {

int front, rear;
front = rear = -1;
String fileName;
String hash;
byte[] receivedData;
FileOutputStream fos;
while(din.available()> 0) {
while (din.available() > 0) {
try {
String str = aes.decrypt(din.readUTF());
if (str.equals("%file%")) {
Expand Down Expand Up @@ -91,34 +92,31 @@ public synchronized void checkandwrite() throws Exception{
dout.writeUTF(aes.encrypt(("%others%" + " " + queue[front++])));
}
}
}catch (Exception e)
{
} catch (Exception e) {
e.printStackTrace();
System.exit(0);
}
}

}
void run_task(){
Task<Thread> task = new Task<>(){

void run_task() {
Task<Thread> task = new Task<>() {

@Override
protected Thread call() throws Exception {

Stage stage ;
Stage stage;
din = new DataInputStream(s.getInputStream());
dout = new DataOutputStream(s.getOutputStream());
stage = (Stage) message.getScene().getWindow();

while(true)
{
while(!stage.isFocused())
{
while (true) {
while (!stage.isFocused()) {
Thread.sleep(200);
}
checkandwrite();
if(!stage.isShowing())
{
if (!stage.isShowing()) {
break;
}
Thread.sleep(100);
Expand All @@ -135,14 +133,13 @@ public void changereceiver() {
dout = new DataOutputStream(s.getOutputStream());
dout.writeUTF(aes.encrypt(("%chat% " + id)));
dout.flush();
}
catch (Exception e)
{
} catch (Exception e) {
e.printStackTrace();
System.exit(0);
}
}
public void encryption_toggle(){

public void encryption_toggle() {
String str;
try {
if (togglebutton.isSelected()) {
Expand Down Expand Up @@ -170,14 +167,13 @@ public void encryption_toggle(){
dout.flush();
myta.clear();
ta.clear();
}
catch (Exception e)
{
} catch (Exception e) {
e.printStackTrace();
System.exit(0);
}
}
public void send_message(){

public void send_message() {
try {
dout = new DataOutputStream(s.getOutputStream());
dout.writeUTF(aes.encrypt(message.getText()));
Expand All @@ -189,14 +185,13 @@ public void send_message(){
}
}
message.clear();
}
catch (Exception e)
{
} catch (Exception e) {
e.printStackTrace();
System.exit(0);
}
}
public void start_file_window(){

public void start_file_window() {
try {
Stage file_chooser = new Stage();
FXMLLoader loader = new FXMLLoader(getClass().getResource("FileChooser.fxml"));
Expand All @@ -208,9 +203,7 @@ public void start_file_window(){
file_chooser.setResizable(false);
file_chooser.setTitle("File sender");
file_chooser.show();
}
catch (Exception e)
{
} catch (Exception e) {
e.printStackTrace();
System.exit(0);
}
Expand Down
26 changes: 11 additions & 15 deletions src/sample/DecryptionController.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@

import static sample.Main.aes;

public class DecryptionController extends Controller{
public class DecryptionController extends Controller {
@FXML
private TextArea ta,ota;
private TextArea ta, ota;

public void transferdata(Socket s)
{
public void transferdata(Socket s) {
this.s = s;
}
public void decryptrequest(){

public void decryptrequest() {
String str;
try {
str = ta.getText();
Expand All @@ -28,28 +28,26 @@ public void decryptrequest(){
dout.writeUTF(aes.encrypt(str));
dout.flush();
ta.clear();
}
catch (Exception e)
{
} catch (Exception e) {
e.printStackTrace();
System.exit(-1);
}
}
public void checkandwrite2(){

public void checkandwrite2() {
try {
din = new DataInputStream(s.getInputStream());
String str;
while (din.available() > 0) {
str = aes.decrypt(din.readUTF());
ota.appendText(str);
}
}
catch (Exception e)
{
} catch (Exception e) {
e.printStackTrace();
System.exit(-1);
}
}

void run_task() {
try {
Task<Thread> task = new Task<>() {
Expand All @@ -71,9 +69,7 @@ protected Thread call() throws Exception {
}
};
new Thread(task).start();
}
catch (Exception e)
{
} catch (Exception e) {
e.printStackTrace();
System.exit(-1);
}
Expand Down
20 changes: 12 additions & 8 deletions src/sample/FileChooser.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,16 @@
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.ListView?>
<?import javafx.scene.layout.AnchorPane?>

<AnchorPane prefHeight="400.0" prefWidth="600.0" styleClass="filechooser" stylesheets="@design.css" xmlns="http://javafx.com/javafx/16" xmlns:fx="http://javafx.com/fxml/1" fx:controller="sample.FileChooserController">
<children>
<Button fx:id="select_one" layoutX="87.0" layoutY="79.0" mnemonicParsing="false" onAction="#selectafile" text="Select a file" />
<Button fx:id="select_multiple" layoutX="87.0" layoutY="175.0" mnemonicParsing="false" onAction="#selectmultiplefiles" text="Select multiple files" />
<ListView fx:id="send_list" layoutX="244.0" layoutY="18.0" opacity="0.7" prefHeight="363.0" prefWidth="325.0" />
<Button fx:id="sendfiles" layoutX="95.0" layoutY="309.0" mnemonicParsing="false" onAction="#sendthefiles" text="Send" />
</children>
<AnchorPane xmlns:fx="http://javafx.com/fxml/1" prefHeight="400.0" prefWidth="600.0" styleClass="filechooser"
stylesheets="@design.css" xmlns="http://javafx.com/javafx/16"
fx:controller="sample.FileChooserController">
<children>
<Button fx:id="select_one" layoutX="87.0" layoutY="79.0" mnemonicParsing="false" onAction="#selectafile"
text="Select a file"/>
<Button fx:id="select_multiple" layoutX="87.0" layoutY="175.0" mnemonicParsing="false"
onAction="#selectmultiplefiles" text="Select multiple files"/>
<ListView fx:id="send_list" layoutX="244.0" layoutY="18.0" opacity="0.7" prefHeight="363.0" prefWidth="325.0"/>
<Button fx:id="sendfiles" layoutX="95.0" layoutY="309.0" mnemonicParsing="false" onAction="#sendthefiles"
text="Send"/>
</children>
</AnchorPane>
Loading

0 comments on commit 7eb8f42

Please sign in to comment.