ajout crypto

This commit is contained in:
2025-03-31 10:06:09 +02:00
parent 731020a934
commit bff1a74ae7
680 changed files with 14849 additions and 0 deletions

19
crypto/TP2/main.c Normal file
View File

@@ -0,0 +1,19 @@
#include <stdio.h>
#include "spn.h"
int main() {
unsigned char s[16] = {14, 3, 2, 10, 12, 11, 15, 9, 0, 4, 7, 13, 1, 8, 6, 5};
unsigned char perm[8] = {5, 2, 0, 4, 6, 1, 7, 3};
unsigned short key = 0xABCD; // Exemple de clé
unsigned char plaintext = 0x3C; // Exemple de bloc clair (0011 1100)
printf("Texte clair : 0x%02X\n", plaintext);
unsigned char ciphertext = encrypt(plaintext, key, perm, s);
printf("Texte chiffré : 0x%02X\n", ciphertext);
unsigned char decrypted = decrypt(ciphertext, key, perm, s);
printf("Texte déchiffré : 0x%02X\n", decrypted);
return 0;
}