Bonjour,
j'ai un code pour crypter des caractères :
et la class :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 public class CrypterPassword { public static void main(String[] args) { Crypter c1 = new Crypter(); Crypter c2 = new Crypter(); Crypter c3 = new Crypter(); Crypter c4 = new Crypter(); c1.encrypt("toto"); c2.encrypt("voituRe"); c3.encrypt("papae"); c4.encrypt("torpille"); c1.AfficheCryptage(); c2.AfficheCryptage(); c3.AfficheCryptage(); c4.AfficheCryptage(); } }
cela me crypte bien les mots, sauf que ca me rajoute un "null" devant le cryptage ? :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 public class Crypter { private String crypte; public String encrypt(String password){ for (int i=0; i<password.length();i++) { int c = password.charAt(i)^48; crypte = crypte + (char)c; } return crypte; } public void AfficheCryptage(){ System.out.println(crypte); } }
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6 run: nullD_D_ nullDEDE null@Q@QU nullD_B@Y\\U BUILD SUCCESSFUL (total time: 0 seconds)
Partager