You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
ServerSocketss = newServerSocket(port); //Creating a server socket
Sockets = ss.accept(); //variable that accepts a servers request
ObjectInputStreaminput = newObjectInputStream(s.getInputStream()); // Object stream for taking the key from the clients stream as input
Keykey = (Key) input.readObject(); // Key is read from the input stream
System.out.println("The ciphered key is :"+key);
Cipherc=Cipher.getInstance("DES"); //getting the DES instance of cipher
c.init(Cipher.DECRYPT_MODE, key);
System.out.println(c); // initializing the decrypting mode with the key from the stream.
CipherInputStreamcis = newCipherInputStream(s.getInputStream(), c); //cis will then contain ascii values of the text.
intvar;
System.out.print("The data sent by client is:");
while((var=cis.read())!=-1) //x has ascii values which are read one by one.
System.out.print(((char)var)); //converting the ascii values to the regular chars and printing it on the console. Note the data here is not store but just displayed on the console.