Télécharger le zip
eviter d introduire tes tps ici monsieur oussite et essyer de faire qlq chose de nouveau ;-)
slt, cmt a tu fait l'executable???
salut Monsieur,l'excellente application que vous avez publié au site(javafr.com)a attiré mon attention,car je suis entrain de réaliser une petite application qui semble mais simple par rapport à la votre.c'est pour cela j'ai besoin de votre aide,et voila une description de mon modeste travai:j'ai fait 3 codes en java bien executés(se sont les pieces jointes avec ce message)un code pour le serveur,le 2 pour le client,et le 3 pour cryptage et decryptage de texte(avec l'algorithme DES).j'execute le code de serveur tout d'abord et ensuite le code du client sans fermer l'execution de code de serveur et comme ça je peux etablir une communication client/serveur.mon probleme est de faire 2 interfaces:*une pour le client:elle contient une zone de texte pour saisir un message,un bouton<crypter>pour crypter le message saisi dans la zone de texte"en exploitant le code de cryptage et decryptage",et un bouton<envoyer>pour envoyer au serveur le message crypté de la zone de texte.*l'autre interface est pour le serveur:elle contient une zone de texte pour afficher le message crypté envoyé par le client,et un bouton<decrypter>pour decrypter le message crypté affiché dans la zone de texte de l'interface(serveur)"en exploitant encore une fois le code de cryptage et decryptage" En attendant une réponse favorable,je vous prie d'agréer,Monsieur,l'expression de mon profond respect.voila les 3 codes: /////////////code pour le serveur///////////////////import java.io.*; // for input outputimport java.lang.*; // for Threadsimport java.net.*; // socketspublic class serverChat { public static void main(String args[]) throws IOException { /*******Declarations**********/ // Ports and Hosts int port = 3000; // port to the PDA client // Sockets ServerSocket serverSocket = null; // ServerSocket //listening to the Client Socket clientSocket = null; // Socket with Client // Inout/Output for PDA Client BufferedReader isClient = null; PrintWriter osClient = null; // Strings String msg_String = null; int msg_hash = 0; int i = 0; int Clientconnected = 0; // Connection marker /********End declarations*********/ /****************Server Socket Creation**********/ System.out.print("\nCreation of the ServerSocket\nlistening to port 3000 \nfor client."); try { System.out.print("."); serverSocket = new ServerSocket(port); //Socket // listening on port 3000 System.out.print("..started.\n\n"); } catch (IOException e) { System.out.print("...failed.\nProblem in the creation of the ServerSocket: " +e); System.exit(1); } try { clientSocket = serverSocket.accept(); Clientconnected = 1; } catch (IOException e) { System.out.println("Unable to deal with BufferedReader and PrintWriter for the clientSocket : " +e); System.exit(1); } /***************End of creation of Sockets*******/ try { isClient = new BufferedReader(new InputStreamReader(clientSocket. getInputStream())); osClient = new PrintWriter (clientSocket.getOutputStream()); } catch (IOException e) { System.out.println("Cant't deal with the streams : " + e); } while (true) { try { msg_String = isClient.readLine(); System.out.println("String from the client : " + msg_String); } catch (IOException e) { System.out.println("Couldn't get I/O for the connection to: "); System.exit(1); } if (msg_String.trim().equals("/bye")) { Clientconnected = 0; clientSocket.close(); serverSocket.close(); System.exit(0); } if (Clientconnected == 1) { try { System.out.print("\nComputing..."); msg_hash = msg_String.hashCode(); System.out.print("done"); osClient.println(msg_hash); osClient.flush(); // put it onto the network System.out.print("...and sent.\n"); } //try catch (Exception e) { System.out.println(e); System.exit(1); } // catch } // if Clientconnected } // while // System.exit(0); } // void main} // PDAServer class////////////code pour client//////////////////import java.io.*; // for input outputimport java.lang.*; // for Threadsimport java.net.*; // socketspublic class clientChat { public static void main(String args[]) throws IOException { /*******Declarations**********/ // Ports and Hosts int port = 3000; // port String myHost = "localhost"; // Sockets Socket clientSocket = null; // Inout/Output for PDA Client BufferedReader isClient = null; PrintWriter osClient = null; BufferedReader readfromline = null; // Strings String myString = null; String sString = null; int i = 0; // Translation counter int Clientconnected = 0; // Connection marker /********End declarations*********/ try { System.out.print("\nClient."); clientSocket = new Socket(myHost, port); System.out.print("..started.\n\n"); } catch (IOException e) { System.out.print("..failed.\nProblem in the creation of the Socket : " + e); System.exit(1); } //catch try { osClient = new PrintWriter(clientSocket.getOutputStream()); isClient = new BufferedReader(new InputStreamReader(clientSocket.getInputStream())); readfromline = new BufferedReader(new InputStreamReader(System.in)); } catch (IOException e) { System.out.println("Can't deal with the streams... : " + e); } //catch try { while (true) { myString = readfromline.readLine(); if (myString.trim().equals("/bye")) { osClient.println("/bye"); osClient.flush(); clientSocket.close(); System.exit(1); } osClient.println(myString); // Write it osClient.flush(); // put it onto the network System.out.println("\nSending...: '" + myString + "' ...done."); myString = isClient.readLine(); System.out.println("From server :-[===> " + myString + "\n"); } //while } //try catch (Exception e) { System.out.println("Exception while sending data" + e); System.exit(1); } // catch System.out.println("Closing connection to client"); // System.exit(0); } // void main} // clientChat class////////////code pour cryptage et decryptage/////////import java.security.*;import javax.crypto.*;// encrypt and decrypt using the DES private key algorpublic class PrivateExemple { public static void main(String[] args) throws Exception { // check args and get plaintext //byte[] plainText = args[0].getBytes("UTF8"); String ss = "je suis un marocain"; byte[] plainText = ss.getBytes(); // get a DES private key System.out.println("\nStart generating DES key"); KeyGenerator keyGen = KeyGenerator.getInstance("DES"); keyGen.init(56); Key key = keyGen.generateKey(); System.out.println("Finish generating DES key"); // get a DES cipher object and print the provide Cipher cipher = Cipher.getInstance("DES/ECB/PKCS5Padding"); System.out.println("\n" + cipher.getProvider().getInfo()); // encrypt using the key and the plaintext System.out.println("\nStart encryption"); cipher.init(Cipher.ENCRYPT_MODE, key); byte[] cipherText = cipher.doFinal(plainText); System.out.println("Finish encryption: "); System.out.println(new String(cipherText, "UTF8")); // decrypt the ciphertext using the same key System.out.println("\nStart decryption"); cipher.init(Cipher.DECRYPT_MODE, key); byte[] newPlainText = cipher.doFinal(cipherText); System.out.println("Finish decryption: "); System.out.println(new String(newPlainText, "UTF8")); }}mon msn est:kamal_tayri@hotmail.com et merci beaucoup
chez moi je reussi pas la le faire fonctionner
Se souvenir du profil
Mot de passe oublié ? / Activation de compteCréer un compte
1 598 161 membres 184 nouveaux aujourd'hui 15 438 membres club