mirror of
https://github.com/LucasVbr/data-encryption-standard.git
synced 2026-05-13 17:12:10 +00:00
fix RemoveCharNull
remove tout les char null maintenant
This commit is contained in:
+11
-11
@@ -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 */
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user