diff --git a/src/cryptography/Des.java b/src/cryptography/Des.java index 0087589..6dcd03b 100644 --- a/src/cryptography/Des.java +++ b/src/cryptography/Des.java @@ -92,6 +92,24 @@ public class Des { System.arraycopy(newTab, 0, bloc, 0, newTab.length); } + public static int[][] decoupage(int[] bloc, int nbBlocs) { + + if(bloc.length % nbBlocs == 0) { + int z = bloc.length / nbBlocs; + int [][] newTab = new int[nbBlocs][z]; + int y = 0; + + for (int i = 0; i < bloc.length ; i++) { + if (i % z == 0 && i > 0) { + y++; + } + newTab[y][i - y * z] = i; + } + return newTab; + } + return null; + } + private static int[] crypte(String message_clair) { // int[] msg_crypte = message_clair.byt return null; // Todo Bouchon diff --git a/src/cryptography/test/testDes.java b/src/cryptography/test/testDes.java index df075bf..8640902 100644 --- a/src/cryptography/test/testDes.java +++ b/src/cryptography/test/testDes.java @@ -53,11 +53,18 @@ public class testDes { System.out.println(Arrays.equals(bloc, bloc2)); } + public static void testDecoupage() { + + System.out.println(Arrays.deepToString(Des.decoupage(new int[]{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19}, 4))); + + } + public static void main(String[] args) { // testStringToBits(); // testBitsToString(); // testGenerePermutation(); // testPermuation(); - testInvPermuation(); + //testInvPermuation(); + testDecoupage(); } }