Ajouts de tests unitaires bitToString et stringToBit

- Réécriture de stringToBit
- Réécriture de bitToString
- Ajout de commentaires
- Ajouts de tests unitaires pour stringToBits
- Ajouts de tests unitaires pour stringToBits
This commit is contained in:
Lucàs
2022-10-26 12:53:02 +02:00
parent 2852716d27
commit c5cad19856
2 changed files with 437 additions and 97 deletions
+143 -75
View File
@@ -5,7 +5,6 @@
*/
package cryptography;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Random;
@@ -59,9 +58,8 @@ public class Des {
24, 25, 26, 27, 28, 29,
28, 29, 30, 31, 32, 1,
};
private final int[] masterKey = new int[64];
public ArrayList<int[]> table_cles;
private int[] masterKey = new int[64];
public Des() {
Random random = new Random();
@@ -71,65 +69,83 @@ public class Des {
this.table_cles = new ArrayList<>();
}
/**
* Crée un nouveau Des avec une masterKey définie (Test/Debug)
*
* @param masterKey Liste d'entiers qui définie la master key (Doit avoir une taille de 64)
*/
public Des(int[] masterKey) {
if (masterKey.length != 64) {
throw new IllegalArgumentException("La masterKey n'est pas composée de 64 bits");
}
this.masterKey = masterKey;
this.table_cles = new ArrayList<>();
}
/* Manipulations de bits et String */
/**
* Converti une chaîne de caractère en sa liste de bits (conversion de caractères ascii en binaire)
*
* @param message Chaîne de caractère à convertir
* @return La liste de bits, resultat de la conversion du message en binaire
*/
public static int[] stringToBits(String message) {
char[] bitsInCharList = new BigInteger(message.getBytes())
.toString(2)
.toCharArray();
int[] bits = new int[bitsInCharList.length];
for (int i = 0; i < bitsInCharList.length; i++) {
bits[i] = Integer.parseInt(String.valueOf(bitsInCharList[i]));
if (message.length() == 0) return new int[]{};
ArrayList<Integer> resultat = new ArrayList<>();
for (char c : message.toCharArray()) {
// Ajoute au résultat la valeur du caractère en binaire
String binaryStringValue = Integer.toBinaryString(c);
String formatedStringValue = String.format("%08d", Integer.parseInt(binaryStringValue));
for (char bit : formatedStringValue.toCharArray()) {
int binaryIntValue = Character.getNumericValue(bit);
resultat.add(binaryIntValue);
}
}
return bits;
}
public static int[] generePermutation(int taille) {
int[] listePermut = new int[taille];
ArrayList<Integer> listeIndice = new ArrayList<>();
// Remplir le tableau d'indice
for (int i = 0; i < taille; i++) {
listeIndice.add(i);
}
Random r = new Random();
for (int i = taille; i > 0; i--) {
listePermut[taille - i] = listeIndice.remove(r.nextInt(i));
}
return listePermut;
return resultat.stream().mapToInt(i -> i).toArray();
}
/**
* Converti une liste de bits en chaîne de caractères
*
* @param blocs liste de bits à convertir
* @return La chaine de caractère
*/
public static String bitsToString(int[] blocs) {
if (blocs.length == 0) return "";
StringBuilder bit = new StringBuilder();
for (int b : blocs) bit.append(b);
// On découpe en bloc de 8bits
int[][] blocsOfOctet = decoupage(blocs, blocs.length / 8);
return new String(new BigInteger(bit.toString(), 2).toByteArray());
}
StringBuilder resultat = new StringBuilder();
for (int[] octet : blocsOfOctet) {
// Convertis l'octet en chaine de caractère
// Ex: [0, 1, 1, 0, 0, 0, 0, 1] -> "01100001"
StringBuilder stringBuilderOctet = new StringBuilder();
for (int i : octet) stringBuilderOctet.append(i);
String stringOctet = stringBuilderOctet.toString();
public static void permutation(int[] tab_permutation, int[] bloc) {
int[] newTab = new int[bloc.length];
for (int i = 0; i < bloc.length; i++) {
// On convertis la chaine de caractère en entier (base 2 -> 10)
int c = Integer.parseInt(stringOctet, 2);
newTab[i] = bloc[tab_permutation[i] % tab_permutation.length];
// On convertis l'entier en caractère et on l'ajoute au message final résultat
resultat.append((char) c);
}
System.arraycopy(newTab, 0, bloc, 0, newTab.length);
}
public static void invPermutation(int[] tab_permutation, int[] bloc) {
int[] newTab = new int[bloc.length];
//// System.out.println(bloc.length);
for (int i = 0; i < bloc.length; i++) {
//// System.out.println(tab_permutation[i] % tab_permutation.length);
newTab[tab_permutation[i] % tab_permutation.length] = bloc[i];
}
System.arraycopy(newTab, 0, bloc, 0, newTab.length);
return resultat.toString();
}
/**
* Découpe un liste de bits en nbBlocs
*
* @param bloc Liste de bits
* @param nbBlocs Nombre de bloc demandé
* @return Une liste de bloc contenant le même nombre de bits
*/
public static int[][] decoupage(int[] bloc, int nbBlocs) {
int surplu = bloc.length % nbBlocs;
int z = (bloc.length) / nbBlocs;
@@ -152,6 +168,29 @@ public class Des {
return newTab;
}
/**
* Effectue un OU exclusif entre deux liste de bits.
* Rappel:
* <ul>
* <li>0 XOR 0 -> 0</li>
* <li>0 XOR 1 -> 1</li>
* <li>1 XOR 0 -> 1</li>
* <li>1 XOR 1 -> 0</li>
* </ul>
*
* @param tab1 Première liste de bits
* @param tab2 Seconde liste de bits
* @return Le résultat du OU exclusif entre tab1 et tab2
*/
public static int[] xor(int[] tab1, int[] tab2) {
int[] resultat = new int[tab1.length];
for (int i = 0; i < resultat.length; i++) {
resultat[i] = (tab1[i] + tab2[i]) % 2;
}
return resultat;
}
public static int[] recollageBloc(int[][] blocs) {
int[] bloc = new int[blocs.length * blocs[0].length];
@@ -177,38 +216,48 @@ public class Des {
return newBloc;
}
public static int[] xor(int[] tab1, int[] tab2) {
int[] resultat = new int[tab1.length];
// System.out.println(resultat.length);
/* Permutations */
public static void permutation(int[] tab_permutation, int[] bloc) {
int[] newTab = new int[bloc.length];
for (int i = 0; i < bloc.length; i++) {
for (int i = 0; i < resultat.length; i++) {
resultat[i] = (tab1[i] + tab2[i]) % 2;
newTab[i] = bloc[tab_permutation[i] % tab_permutation.length];
}
return resultat;
System.arraycopy(newTab, 0, bloc, 0, newTab.length);
}
public void genereCle(int n) {
int[] newCle = new int[56];
int[] lastCle = new int[48];
int[] permInit = generePermutation(newCle.length);
permutation(permInit, newCle);
public static void invPermutation(int[] tab_permutation, int[] bloc) {
int[] newTab = new int[bloc.length];
System.arraycopy(this.masterKey, 0, newCle, 0, newCle.length);
//// System.out.println(bloc.length);
for (int i = 0; i < bloc.length; i++) {
//// System.out.println(tab_permutation[i] % tab_permutation.length);
int[][] cleDecoupe = decoupage(newCle, 2);
assert cleDecoupe != null;
cleDecoupe[0] = decaleGauche(cleDecoupe[0], TAB_DECALAGE[n]);
cleDecoupe[1] = decaleGauche(cleDecoupe[1], TAB_DECALAGE[n]);
newTab[tab_permutation[i] % tab_permutation.length] = bloc[i];
}
newCle = recollageBloc(cleDecoupe);
int[] lastPerm = generePermutation(lastCle.length);
System.arraycopy(newCle, 0, lastCle, 0, lastCle.length);
permutation(lastPerm, lastCle);
this.table_cles.add(lastCle);
System.arraycopy(newTab, 0, bloc, 0, newTab.length);
}
public static int[] generePermutation(int taille) {
int[] listePermut = new int[taille];
ArrayList<Integer> listeIndice = new ArrayList<>();
// Remplir le tableau d'indice
for (int i = 0; i < taille; i++) {
listeIndice.add(i);
}
Random r = new Random();
for (int i = taille; i > 0; i--) {
listePermut[taille - i] = listeIndice.remove(r.nextInt(i));
}
return listePermut;
}
/* Fonctions */
public static int[] fonction_S(int[] tab) {
String l = "" + tab[0] + tab[5];
@@ -228,6 +277,27 @@ public class Des {
return resultat;
}
/* Genere */
public void genereCle(int n) {
int[] newCle = new int[56];
int[] lastCle = new int[48];
int[] permInit = generePermutation(newCle.length);
permutation(permInit, newCle);
System.arraycopy(this.masterKey, 0, newCle, 0, newCle.length);
int[][] cleDecoupe = decoupage(newCle, 2);
cleDecoupe[0] = decaleGauche(cleDecoupe[0], TAB_DECALAGE[n]);
cleDecoupe[1] = decaleGauche(cleDecoupe[1], TAB_DECALAGE[n]);
newCle = recollageBloc(cleDecoupe);
int[] lastPerm = generePermutation(lastCle.length);
System.arraycopy(newCle, 0, lastCle, 0, lastCle.length);
permutation(lastPerm, lastCle);
this.table_cles.add(lastCle);
}
public int[] fonction_F(int indice_cle, int[] Dn) {
//xor entre this.E et la cle trouvé à cette ronde
int[] cle = this.table_cles.get(indice_cle);
@@ -248,6 +318,7 @@ public class Des {
return recollageBloc(bloc);
}
/* Methodes générales */
public int[] crypte(String message_clair) {
int[] msg_bit = stringToBits(message_clair);
@@ -293,9 +364,7 @@ public class Des {
}
public String decrypte(int[] messageCode) {
int[][] decoupe = decoupage(messageCode, (int) (messageCode.length / TAILLE_BLOC));
int[][] decoupe = decoupage(messageCode, messageCode.length / TAILLE_BLOC);
for (int i = 0; i < decoupe.length; i++) {
permutation(PERM_INITIALE, decoupe[i]);
@@ -313,7 +382,6 @@ public class Des {
}
decoupe[i] = recollageBloc(bloc32);
invPermutation(PERM_INITIALE, decoupe[i]);
}
int[] message_decrypte = recollageBloc(decoupe);
return bitsToString(message_decrypte);
+294 -22
View File
@@ -2,6 +2,7 @@ package cryptography;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Order;
import org.junit.jupiter.api.Test;
import java.util.HashMap;
@@ -11,75 +12,346 @@ import static org.junit.jupiter.api.Assertions.*;
class DesTest {
@BeforeEach
void setUp() {
}
@AfterEach
void tearDown() {
}
// @BeforeEach
// void setUp() {
//
// }
//
// @AfterEach
// void tearDown() {
// }
@Test
void stringToBits() {
HashMap<String, int[]> attendu = new HashMap<>() {{
put("Bonjour", new int[]{0, 1, 0, 0, 0, 0, 1, 0, 0, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 0, 1, 1, 1, 0, 0, 1, 1, 0, 1, 0, 1, 0, 0, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 1, 0});
HashMap<String, int[]> TESTS = new HashMap<>() {{
// Empty string
put("", new int[]{});
// abc, maj
put("abcdefghijklmnopqrstuvwxyz", new int[]{
0, 1, 1, 0, 0, 0, 0, 1, // a
0, 1, 1, 0, 0, 0, 1, 0, // b
0, 1, 1, 0, 0, 0, 1, 1, // c
0, 1, 1, 0, 0, 1, 0, 0, // d
0, 1, 1, 0, 0, 1, 0, 1, // e
0, 1, 1, 0, 0, 1, 1, 0, // f
0, 1, 1, 0, 0, 1, 1, 1, // g
0, 1, 1, 0, 1, 0, 0, 0, // h
0, 1, 1, 0, 1, 0, 0, 1, // i
0, 1, 1, 0, 1, 0, 1, 0, // j
0, 1, 1, 0, 1, 0, 1, 1, // k
0, 1, 1, 0, 1, 1, 0, 0, // l
0, 1, 1, 0, 1, 1, 0, 1, // m
0, 1, 1, 0, 1, 1, 1, 0, // n
0, 1, 1, 0, 1, 1, 1, 1, // o
0, 1, 1, 1, 0, 0, 0, 0, // p
0, 1, 1, 1, 0, 0, 0, 1, // q
0, 1, 1, 1, 0, 0, 1, 0, // r
0, 1, 1, 1, 0, 0, 1, 1, // s
0, 1, 1, 1, 0, 1, 0, 0, // t
0, 1, 1, 1, 0, 1, 0, 1, // u
0, 1, 1, 1, 0, 1, 1, 0, // v
0, 1, 1, 1, 0, 1, 1, 1, // w
0, 1, 1, 1, 1, 0, 0, 0, // x
0, 1, 1, 1, 1, 0, 0, 1, // y
0, 1, 1, 1, 1, 0, 1, 0, // z
});
put("ABCDEFGHIJKLMNOPQRSTUVWXYZ", new int[]{
0, 1, 0, 0, 0, 0, 0, 1, // A
0, 1, 0, 0, 0, 0, 1, 0, // B
0, 1, 0, 0, 0, 0, 1, 1, // C
0, 1, 0, 0, 0, 1, 0, 0, // D
0, 1, 0, 0, 0, 1, 0, 1, // E
0, 1, 0, 0, 0, 1, 1, 0, // F
0, 1, 0, 0, 0, 1, 1, 1, // G
0, 1, 0, 0, 1, 0, 0, 0, // H
0, 1, 0, 0, 1, 0, 0, 1, // I
0, 1, 0, 0, 1, 0, 1, 0, // J
0, 1, 0, 0, 1, 0, 1, 1, // K
0, 1, 0, 0, 1, 1, 0, 0, // L
0, 1, 0, 0, 1, 1, 0, 1, // M
0, 1, 0, 0, 1, 1, 1, 0, // N
0, 1, 0, 0, 1, 1, 1, 1, // O
0, 1, 0, 1, 0, 0, 0, 0, // P
0, 1, 0, 1, 0, 0, 0, 1, // Q
0, 1, 0, 1, 0, 0, 1, 0, // R
0, 1, 0, 1, 0, 0, 1, 1, // S
0, 1, 0, 1, 0, 1, 0, 0, // T
0, 1, 0, 1, 0, 1, 0, 1, // U
0, 1, 0, 1, 0, 1, 1, 0, // V
0, 1, 0, 1, 0, 1, 1, 1, // W
0, 1, 0, 1, 1, 0, 0, 0, // X
0, 1, 0, 1, 1, 0, 0, 1, // Y
0, 1, 0, 1, 1, 0, 1, 0, // Z
});
// Numbers
put("0123456789", new int[]{
0, 0, 1, 1, 0, 0, 0, 0, // 0
0, 0, 1, 1, 0, 0, 0, 1, // 1
0, 0, 1, 1, 0, 0, 1, 0, // 2
0, 0, 1, 1, 0, 0, 1, 1, // 3
0, 0, 1, 1, 0, 1, 0, 0, // 4
0, 0, 1, 1, 0, 1, 0, 1, // 5
0, 0, 1, 1, 0, 1, 1, 0, // 6
0, 0, 1, 1, 0, 1, 1, 1, // 7
0, 0, 1, 1, 1, 0, 0, 0, // 8
0, 0, 1, 1, 1, 0, 0, 1, // 9
});
// Special chars
put("+-/*%=", new int[]{
0, 0, 1, 0, 1, 0, 1, 1, // +
0, 0, 1, 0, 1, 1, 0, 1, // -
0, 0, 1, 0, 1, 1, 1, 1, // /
0, 0, 1, 0, 1, 0, 1, 0, // *
0, 0, 1, 0, 0, 1, 0, 1, // %
0, 0, 1, 1, 1, 1, 0, 1, // =
});
put("?!.,;:_ ", new int[]{
0, 0, 1, 1, 1, 1, 1, 1, // ?
0, 0, 1, 0, 0, 0, 0, 1, // !
0, 0, 1, 0, 1, 1, 1, 0, // .
0, 0, 1, 0, 1, 1, 0, 0, // ,
0, 0, 1, 1, 1, 0, 1, 1, // ;
0, 0, 1, 1, 1, 0, 1, 0, // :
0, 1, 0, 1, 1, 1, 1, 1, // _
0, 0, 1, 0, 0, 0, 0, 0, // space
});
put("(){}[]", new int[]{
0, 0, 1, 0, 1, 0, 0, 0, // (
0, 0, 1, 0, 1, 0, 0, 1, // )
0, 1, 1, 1, 1, 0, 1, 1, // {
0, 1, 1, 1, 1, 1, 0, 1, // }
0, 1, 0, 1, 1, 0, 1, 1, // [
0, 1, 0, 1, 1, 1, 0, 1, // ]
});
put("&@#^\"'`", new int[]{
0, 0, 1, 0, 0, 1, 1, 0, // &
0, 1, 0, 0, 0, 0, 0, 0, // @
0, 0, 1, 0, 0, 0, 1, 1, // #
0, 1, 0, 1, 1, 1, 1, 0, // ^
0, 0, 1, 0, 0, 0, 1, 0, // "
0, 0, 1, 0, 0, 1, 1, 1, // '
0, 1, 1, 0, 0, 0, 0, 0, // `
});
// Custom test
put("Bonjour", new int[]{
0, 1, 0, 0, 0, 0, 1, 0, // B
0, 1, 1, 0, 1, 1, 1, 1, // o
0, 1, 1, 0, 1, 1, 1, 0, // n
0, 1, 1, 0, 1, 0, 1, 0, // j
0, 1, 1, 0, 1, 1, 1, 1, // o
0, 1, 1, 1, 0, 1, 0, 1, // u
0, 1, 1, 1, 0, 0, 1, 0, // r
});
}};
for (Map.Entry<String, int[]> test : attendu.entrySet()) {
assertArrayEquals(Des.stringToBits(test.getKey()), test.getValue());
for (Map.Entry<String, int[]> test : TESTS.entrySet()) {
assertArrayEquals(test.getValue(), Des.stringToBits(test.getKey()));
System.out.println(test.getKey() + " -> Ok");
}
}
@Test
void generePermutation() {
}
@Test
void bitsToString() {
}
HashMap<int[], String> TESTS = new HashMap<>() {{
// Empty string
put(new int[]{}, "");
@Test
void permutation() {
}
// abc, maj
put(new int[]{
0, 1, 1, 0, 0, 0, 0, 1, // a
0, 1, 1, 0, 0, 0, 1, 0, // b
0, 1, 1, 0, 0, 0, 1, 1, // c
0, 1, 1, 0, 0, 1, 0, 0, // d
0, 1, 1, 0, 0, 1, 0, 1, // e
0, 1, 1, 0, 0, 1, 1, 0, // f
0, 1, 1, 0, 0, 1, 1, 1, // g
0, 1, 1, 0, 1, 0, 0, 0, // h
0, 1, 1, 0, 1, 0, 0, 1, // i
0, 1, 1, 0, 1, 0, 1, 0, // j
0, 1, 1, 0, 1, 0, 1, 1, // k
0, 1, 1, 0, 1, 1, 0, 0, // l
0, 1, 1, 0, 1, 1, 0, 1, // m
0, 1, 1, 0, 1, 1, 1, 0, // n
0, 1, 1, 0, 1, 1, 1, 1, // o
0, 1, 1, 1, 0, 0, 0, 0, // p
0, 1, 1, 1, 0, 0, 0, 1, // q
0, 1, 1, 1, 0, 0, 1, 0, // r
0, 1, 1, 1, 0, 0, 1, 1, // s
0, 1, 1, 1, 0, 1, 0, 0, // t
0, 1, 1, 1, 0, 1, 0, 1, // u
0, 1, 1, 1, 0, 1, 1, 0, // v
0, 1, 1, 1, 0, 1, 1, 1, // w
0, 1, 1, 1, 1, 0, 0, 0, // x
0, 1, 1, 1, 1, 0, 0, 1, // y
0, 1, 1, 1, 1, 0, 1, 0, // z
}, "abcdefghijklmnopqrstuvwxyz");
@Test
void invPermutation() {
put(new int[]{
0, 1, 0, 0, 0, 0, 0, 1, // A
0, 1, 0, 0, 0, 0, 1, 0, // B
0, 1, 0, 0, 0, 0, 1, 1, // C
0, 1, 0, 0, 0, 1, 0, 0, // D
0, 1, 0, 0, 0, 1, 0, 1, // E
0, 1, 0, 0, 0, 1, 1, 0, // F
0, 1, 0, 0, 0, 1, 1, 1, // G
0, 1, 0, 0, 1, 0, 0, 0, // H
0, 1, 0, 0, 1, 0, 0, 1, // I
0, 1, 0, 0, 1, 0, 1, 0, // J
0, 1, 0, 0, 1, 0, 1, 1, // K
0, 1, 0, 0, 1, 1, 0, 0, // L
0, 1, 0, 0, 1, 1, 0, 1, // M
0, 1, 0, 0, 1, 1, 1, 0, // N
0, 1, 0, 0, 1, 1, 1, 1, // O
0, 1, 0, 1, 0, 0, 0, 0, // P
0, 1, 0, 1, 0, 0, 0, 1, // Q
0, 1, 0, 1, 0, 0, 1, 0, // R
0, 1, 0, 1, 0, 0, 1, 1, // S
0, 1, 0, 1, 0, 1, 0, 0, // T
0, 1, 0, 1, 0, 1, 0, 1, // U
0, 1, 0, 1, 0, 1, 1, 0, // V
0, 1, 0, 1, 0, 1, 1, 1, // W
0, 1, 0, 1, 1, 0, 0, 0, // X
0, 1, 0, 1, 1, 0, 0, 1, // Y
0, 1, 0, 1, 1, 0, 1, 0, // Z
}, "ABCDEFGHIJKLMNOPQRSTUVWXYZ");
// Numbers
put(new int[]{
0, 0, 1, 1, 0, 0, 0, 0, // 0
0, 0, 1, 1, 0, 0, 0, 1, // 1
0, 0, 1, 1, 0, 0, 1, 0, // 2
0, 0, 1, 1, 0, 0, 1, 1, // 3
0, 0, 1, 1, 0, 1, 0, 0, // 4
0, 0, 1, 1, 0, 1, 0, 1, // 5
0, 0, 1, 1, 0, 1, 1, 0, // 6
0, 0, 1, 1, 0, 1, 1, 1, // 7
0, 0, 1, 1, 1, 0, 0, 0, // 8
0, 0, 1, 1, 1, 0, 0, 1, // 9
}, "0123456789");
// Special chars
put(new int[]{
0, 0, 1, 0, 1, 0, 1, 1, // +
0, 0, 1, 0, 1, 1, 0, 1, // -
0, 0, 1, 0, 1, 1, 1, 1, // /
0, 0, 1, 0, 1, 0, 1, 0, // *
0, 0, 1, 0, 0, 1, 0, 1, // %
0, 0, 1, 1, 1, 1, 0, 1, // =
}, "+-/*%=");
put(new int[]{
0, 0, 1, 1, 1, 1, 1, 1, // ?
0, 0, 1, 0, 0, 0, 0, 1, // !
0, 0, 1, 0, 1, 1, 1, 0, // .
0, 0, 1, 0, 1, 1, 0, 0, // ,
0, 0, 1, 1, 1, 0, 1, 1, // ;
0, 0, 1, 1, 1, 0, 1, 0, // :
0, 1, 0, 1, 1, 1, 1, 1, // _
0, 0, 1, 0, 0, 0, 0, 0, // space
}, "?!.,;:_ ");
put(new int[]{
0, 0, 1, 0, 1, 0, 0, 0, // (
0, 0, 1, 0, 1, 0, 0, 1, // )
0, 1, 1, 1, 1, 0, 1, 1, // {
0, 1, 1, 1, 1, 1, 0, 1, // }
0, 1, 0, 1, 1, 0, 1, 1, // [
0, 1, 0, 1, 1, 1, 0, 1, // ]
}, "(){}[]");
put(new int[]{
0, 0, 1, 0, 0, 1, 1, 0, // &
0, 1, 0, 0, 0, 0, 0, 0, // @
0, 0, 1, 0, 0, 0, 1, 1, // #
0, 1, 0, 1, 1, 1, 1, 0, // ^
0, 0, 1, 0, 0, 0, 1, 0, // "
0, 0, 1, 0, 0, 1, 1, 1, // '
0, 1, 1, 0, 0, 0, 0, 0, // `
}, "&@#^\"'`");
// Custom test
put(new int[]{
0, 1, 0, 0, 0, 0, 1, 0, // B
0, 1, 1, 0, 1, 1, 1, 1, // o
0, 1, 1, 0, 1, 1, 1, 0, // n
0, 1, 1, 0, 1, 0, 1, 0, // j
0, 1, 1, 0, 1, 1, 1, 1, // o
0, 1, 1, 1, 0, 1, 0, 1, // u
0, 1, 1, 1, 0, 0, 1, 0, // r
}, "Bonjour");
}};
for (Map.Entry<int[], String> test : TESTS.entrySet()) {
assertEquals(test.getValue(), Des.bitsToString(test.getKey()));
System.out.println(test.getValue() + " -> Ok");
}
}
@Test
void decoupage() {
assertTrue(false); // TODO
}
@Test
void generePermutation() {
assertTrue(false); // TODO
}
@Test
void permutation() {
assertTrue(false); // TODO
}
@Test
void invPermutation() {
assertTrue(false); // TODO
}
@Test
void recollageBloc() {
assertTrue(false); // TODO
}
@Test
void decaleGauche() {
assertTrue(false); // TODO
}
@Test
void xor() {
assertTrue(false); // TODO
}
@Test
void genereCle() {
assertTrue(false); // TODO
}
@Test
void fonction_S() {
assertTrue(false); // TODO
}
@Test
void fonction_F() {
assertTrue(false); // TODO
}
@Test
void crypte() {
assertTrue(false); // TODO
}
@Test
void decrypte() {
assertTrue(false); // TODO
}
}