Bonjour, j'essaye de hasher un mot de passe,avec l'algorithme DES,
Je récupere le toto codé (par exemple) ØÖÆd‚—Jh
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10 String ss = "toto"; byte[] plainText = ss.getBytes(); KeyGenerator keyGen = KeyGenerator.getInstance("DES"); keyGen.init(56); Key key = keyGen.generateKey(); Cipher cipher = Cipher.getInstance("DES/ECB/PKCS5Padding"); cipher.init(Cipher.ENCRYPT_MODE, key); byte[] cipherText = cipher.doFinal(plainText); System.out.println(new String(cipherText, "UTF8"));
pour décoder
J'ai une exception :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10 String ss = "ØÖÆdJh"; byte[] plainText = ss.getBytes(); System.out.println("\nStart generating DES key"); KeyGenerator keyGen = KeyGenerator.getInstance("DES"); keyGen.init(56); Key key = keyGen.generateKey(); Cipher cipher = Cipher.getInstance("DES/ECB/PKCS5Padding"); cipher.init(Cipher.DECRYPT_MODE, key); byte[] newPlainText = cipher.doFinal(plainText);
Code : Sélectionner tout - Visualiser dans une fenêtre à part Exception in thread "main" javax.crypto.BadPaddingException: Given final block not properly padded![]()
Je dois faire une grosse erreur mais je ne vois pas ou
merci








Répondre avec citation


OK !!! OK !!!! tirez plus sur le pianiste. Il est vrai que je me suis lancé à la légere sur ce sujet.

Partager