Test fonction_S

test de la fonction_S
This commit is contained in:
Laurian-Dufrechou
2022-11-04 18:02:32 +01:00
parent f56ffc4c48
commit 4ca0314703
2 changed files with 10 additions and 8 deletions
+1 -1
View File
@@ -61,7 +61,7 @@ public class Des {
24, 25, 26, 27, 28, 29,
28, 29, 30, 31, 32, 1,
};
private final ArrayList<int[][]> table_S;
public final ArrayList<int[][]> table_S;
public ArrayList<int[]> table_cles;
private int[] masterKey = new int[64];
+9 -7
View File
@@ -439,15 +439,17 @@ class DesTest {
void fonction_S() {
// TODO
Des des = new Des();
int[][] S = {
{14, 4, 13, 1, 2, 15, 11, 8, 3, 10, 6, 12, 5, 9, 0, 7},
{0, 15, 7, 4, 14, 2, 13, 1, 10, 6, 12, 11, 9, 5, 3, 8},
{4, 1, 14, 8, 13, 6, 2, 11, 15, 12, 9, 7, 3, 10, 5, 0},
{15, 12, 8, 2, 4, 9, 1, 7, 5, 11, 3, 14, 10, 0, 6, 13}
};
des.genereS(0);
int resultat_attendu_int = des.tableS.get(3).get(9);
int[] resultat_attendu = new int[4];
for (int i = 0; i < resultat_attendu.length; i++, resultat_attendu_int /= 10) {
resultat_attendu[resultat_attendu.length - i - 1] = resultat_attendu_int % 10;
}
// assertArrayEquals(<attendu>, des.fonction_S(...))
assertArrayEquals(resultat_attendu, des.fonction_S(new int[] {1,1,0,0,1,1}));
}