ajout crypto
This commit is contained in:
19
crypto/TP2/main.c
Normal file
19
crypto/TP2/main.c
Normal 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;
|
||||
}
|
||||
Reference in New Issue
Block a user