Advertisement
Vincent38190

Chiffrement TPE [v1.1]

Jan 17th, 2016
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.65 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4. #include <math.h>
  5. #include "algorithme.h"
  6. #define TAILLE_MAX 1000
  7. //algorithme.c : http://pastebin.com/iXqSh0UR
  8. //algorithme.h : http://pastebin.com/EC1GWPcu
  9.  
  10.  
  11. int main(int argc, char *argv[])
  12. {
  13.     while(1)
  14.     {
  15.         char messagesNonCrypte[TAILLE_MAX] = "", messagesCrypte[TAILLE_MAX] = "";
  16.         int cle = 0, choix = 0;
  17.         printf("\nChoix 1 : Chiffrement\nChoix 2 : Dechiffrement\nChoix 3 : Montrer ancien message\nChoix 4 : Quitter\nVotre choix ? ");
  18.         scanf("%d", &choix);
  19.         if(choix == 1) //Chiffrement
  20.         {
  21.             printf("Quelle est le message ? (utiliser \"_\" pour les espaces)\nMessage : ");
  22.             scanf("%s",messagesNonCrypte);
  23.             printf("Quelle est la cle ?\nCle : ");
  24.             scanf("%d",&cle);
  25.             Chiffrement(messagesNonCrypte,messagesCrypte,cle);
  26.             printf("Le message crypte est : %s",messagesCrypte);
  27.         }
  28.         else if(choix == 2) //Dechiffrement
  29.         {
  30.              printf("Quelle est le message ? (utiliser \"_\" pour les espaces)\nMessage : ");
  31.             scanf("%s",messagesCrypte);
  32.             printf("Quelle est la cle ?\nCle : ");
  33.             scanf("%d",&cle);
  34.             Dechiffrement(messagesCrypte,messagesNonCrypte,cle);
  35.             printf("Le message decrypte est : %s",messagesNonCrypte);
  36.         }
  37.         else if(choix == 3) //SAVE
  38.         {
  39.             AfficherSave();
  40.         }
  41.         else if(choix == 4) //EXIT
  42.         {
  43.             goto FIN;
  44.         }
  45.         else
  46.         {
  47.             printf("Erreur mauvais choix\n");
  48.         }
  49.  
  50.     }
  51.     FIN:
  52.     return 0;
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement