fix RemoveCharNull

remove tout les char null maintenant
This commit is contained in:
Laurian-Dufrechou
2022-10-26 20:25:14 +02:00
parent 141e30108d
commit 86b4083482
2 changed files with 12 additions and 12 deletions
+11 -11
View File
@@ -290,20 +290,20 @@ public class Des {
int[][] blocsOfOctet = decoupage(message_decrypte, message_decrypte.length / 8);
ArrayList<Integer> msg_decrypt = new ArrayList<>();
int[] octet = blocsOfOctet[blocsOfOctet.length - 1];
StringBuilder stringBuilderOctet = new StringBuilder();
for (int i : octet) stringBuilderOctet.append(i);
String stringOctet = stringBuilderOctet.toString();
int c = Integer.parseInt(stringOctet, 2);
for (int[] octet: blocsOfOctet){
StringBuilder stringBuilderOctet = new StringBuilder();
for (int i : octet) stringBuilderOctet.append(i);
String stringOctet = stringBuilderOctet.toString();
int c = Integer.parseInt(stringOctet, 2);
if ((char) c == 0) {
int[] newTab = new int[message_decrypte.length - 8];
System.arraycopy(message_decrypte, 0, newTab, 0, newTab.length);
return newTab;
} else {
return message_decrypte;
if ((char) c != 0) {
for (int i : octet) msg_decrypt.add(i);
}
}
return msg_decrypt.stream().mapToInt(i->i).toArray();
}
/* Genere */
+1 -1
View File
@@ -107,7 +107,7 @@ public class testDes {
private static void testDecrypte() {
Des des = new Des();
int[] msg = des.crypte("Bonjour");
int[] msg = des.crypte("Bonjour, je suis super heureux de vous voir");
System.out.println("Message crypté : " + Des.bitsToString(msg));
System.out.println(des.decrypte(msg));
}