/* Encrypted file transfer protocol, by Chuck Liang */ /* server */ import java.io.*; import java.net.*; public class eftp { static String instring, outstring; static final int eport = 1902; static ServerSocket ssocket; // listening, passive socket public static void main(String[] args) { try { ssocket = new ServerSocket(eport); System.out.println("eftp server running ..."); while (true) { Socket csocket = ssocket.accept(); // wait for client csocket.setSoTimeout(30000); // 30 second timeout on reads ethread newthread = new ethread(csocket); newthread.start(); } // end while } catch (Exception E) { System.err.println(E.toString()); } } // end main } // end eftp class ethread extends Thread { Socket csocket; ethread(Socket s) { super(); csocket = s; } // constructor /* encryption routines: */ static char scramble2(char c, char previous) { int pval = (int) previous; int cval = (int) c; int ciphercode = 0; // code for ciphertext if ((pval%2) == 0) // pval is even ciphercode = cval + 2; else // pval is odd ciphercode = cval + 3; return (char) ciphercode; } static String encryptString2(String A) { String Newstring = ""; char previous = (char) 32; int length = A.length(); for(int i=0;i