Asymmetric encryption client/server
The AsymmetricKeyUtility
class developed in asymmetric encryption techniques is used to support the client and server applications. We will use it's encrypt
and decrypt
methods. The structure of the client and server applications is similar to what was used in previous sections. The client will send the server an encrypted message, which the server will decrypt and then respond to with plain text.
Asymmetric server application
The AsymmetricEchoServer
class, as declared next, is used for the server. The main
method is its only method. A server socket is created, which blocks at the accept
method waiting for client request:
public class AsymmetricEchoServer { public static void main(String[] args) { System.out.println("Simple Echo Server"); try (ServerSocket serverSocket = new ServerSocket(6000)) { System.out.println("Waiting for connection....."); Socket clientSocket = serverSocket.accept(); System...