logo

Client and Server Application | Report

Develop a secure communication system for the Rebellion using client and server programs.

16 Pages1570 Words21 Views
   

Added on  2022-08-11

About This Document

NA

Client and Server Application | Report

Develop a secure communication system for the Rebellion using client and server programs.

   Added on 2022-08-11

ShareRelated Documents
Running Head: Client and Server Application
Client and Server Application
Name of the Student
Name of the University
Author Name
Client and Server Application | Report_1
1Progaming Detalis
Overview of the program
The program is based on an interaction between client and server. At first, the server sends the
start with the port number and went for the client. After that, the client starts with local host, port no
and user id. Let both servers and clients are ready to interact with each other. Client sends a message at
server. Massage send though encryption mode and send to server. In server, message is decrypting and
show both encrypt and decrypt the message. Along with when the time of start client and server both
show the current time and date. Also in the time of sending message date and time also visible.
Description
The program consists of three class Client-Server and Massage. At first start server-class then
server show wait for a client. Then start the Client class. At the start of the client class, there are must
give a hostname, port no and user id. The server class also starts with the port number. Now the client
and server ready for communication. Then client sends a massage to sever through the web socket and
the server received it. Also, Server sends the reply message to client with the socket. In the program,
there is encrypt and decrypt method for security purposes. For the purpose of encryption and
decryption use the AES SHA-256 Algorithm process. This algorithm used a security key for
encrypting or decrypting process. When the client and server send the message, it encrypts and
decrypts with the key.
Represent of Programing code
Client class
package _package;
import java.net.*;
import java.io.*;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
Client and Server Application | Report_2
2Progaming Detalis
import java.util.Arrays;
import java.util.Base64;
import java.util.Scanner;
import javax.crypto.Cipher;
import javax.crypto.spec.SecretKeySpec;
public class Client
{
// initialize socket and input output streams
private Socket socket = null;
private byte[] key;
private DataInputStream input = null;
private DataOutputStream out = null;
private BufferedReader br;
private static SecretKeySpec secretKey;
static String address;
static int port;
static String userid;
final String secretKey1 = "ssshhhhhhhhhhh!!!!";
long millis=System.currentTimeMillis();
java.util.Date date=new java.util.Date(millis);
// constructor to put ip address and port
public Client(String address, int port,String userid1) throws IOException
{
this.address=address;
Client and Server Application | Report_3
3Progaming Detalis
this.port=port;
this.userid=userid1;
MessageDigest sha = null;
// establish a connection
socket = new Socket(address, port);
System.out.println("Connected With Server");
System.out.println("Client"+" "+userid1);
System.out.println(date);
try {
key = userid1.getBytes("UTF-8");
sha = MessageDigest.getInstance("SHA-256");
key = sha.digest(key);
key= Arrays.copyOf(key, 16);
secretKey = new SecretKeySpec(key, "AES");
}
catch (NoSuchAlgorithmException | UnsupportedEncodingException e) {
e.printStackTrace();
}
// to send data to the server
DataOutputStream dos
= new DataOutputStream(
socket.getOutputStream());
// to read data coming from the server
Client and Server Application | Report_4

End of preview

Want to access all the pages? Upload your documents or become a member.

Related Documents
Program Description | Document
|15
|1603
|24

Code for Proxy Cache Assignment - Desklib
|7
|1720
|105

Client Server System for Socket Programming | Desklib
|18
|1451
|253

Client Server Programming - Desklib
|9
|1289
|365

Client Server Programming Using RSA
|9
|1136
|384

Desklib - Online Library for Study Material with Solved Assignments, Essays, Dissertations
|27
|4351
|287