jaafar Posted March 31, 2011 Share Posted March 31, 2011 salut j'ai utilisé ce code pour le cryptage et décryptage des j'ai aucune erreur mais quand je fait run il me affiche un message d'exception voila le code import java.security.*; import javax.crypto.*; // // encrypt and decrypt using the DES private key algorithm public class PrivateExample { public static void main(String[] args) throws Exception { // // check args and get plaintext if (args.length != 1) { System.err.println("Usage: java PrivateExample text"); System.exit(1); } // byte[] plainText = args[0].getBytes("UTF8"); String ss = "Hello world, haris is here!"; 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 provider 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")); } } Link to comment Share on other sites More sharing options...
chpil Posted March 31, 2011 Share Posted March 31, 2011 Et si tu ne nous dis pas quelle exception/erreur se produit, on ne va pas beaucoup pouvoir t'aider... Link to comment Share on other sites More sharing options...
jaafar Posted March 31, 2011 Author Share Posted March 31, 2011 Et si tu ne nous dis pas quelle exception/erreur se produit, on ne va pas beaucoup pouvoir t'aider... oui quand je lance run il m'affiche un message de ce genre # # JRE version: 6.0_24-b07 # Java VM: Java HotSpot(TM) 64-Bit Server VM (19.1-b02 mixed mode windows-amd64 compressed oops) # An error report file with more information is saved as: # C:\Users\hp\Cryptage DES\hs_err_pid5136.log # # If you would like to submit a bug report, please visit: # http://java.sun.com/webapps/bugreport/crash.jsp # Link to comment Share on other sites More sharing options...
chpil Posted March 31, 2011 Share Posted March 31, 2011 Y'a un truc qui m'échappe... Tu l'exécutes dans quel environnement, ce code ? Quel rapport entre la fenêtre d'erreur Android et la "trace" d'exécution d'une JVM Windows ??? Mais, tout cela ne nous avance pas plus, on ne sait toujours pas quelle erreur se produit: ce qui pourrait vraiment aider, c'est d'avoir la trace de l'exception qui se produit... Link to comment Share on other sites More sharing options...
jaafar Posted March 31, 2011 Author Share Posted March 31, 2011 Y'a un truc qui m'échappe... Tu l'exécutes dans quel environnement, ce code ? Quel rapport entre la fenêtre d'erreur Android et la "trace" d'exécution d'une JVM Windows ??? Mais, tout cela ne nous avance pas plus, on ne sait toujours pas quelle erreur se produit: ce qui pourrait vraiment aider, c'est d'avoir la trace de l'exception qui se produit... pour 1ére fénétre d'erreur android j'ai fait RUN android application pour 2 éme code j'ai fait RUN avec Java application Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.