Advertisement
Vincent38190

Chiffrement TPE v5

Jan 25th, 2016
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.99 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.  /*
  8.  Algorithme.c : http://pastebin.com/RScbE00T
  9.  Algorithme.h : http://pastebin.com/An8XnG2D
  10.  */
  11.  
  12. int main(int argc, char *argv[])
  13. {
  14.     srand(time(NULL));
  15.     while(1)
  16.     {
  17.         char messagesNonCrypte[TAILLE_MAX] = "", messagesCrypte[TAILLE_MAX] = "";
  18.         long cle = 0, choix = 0;
  19.         printf("\nChoix 1 : Chiffrement\nChoix 2 : Dechiffrement\nChoix 3 : Montrer ancien message\nChoix 4 : Quitter\nVotre choix ? ");
  20.         //scanf("%d", &choix);
  21.         choix = lireLong();
  22.         if(choix == 1) //Chiffrement
  23.         {
  24.             printf("Quelle est le message ? (utiliser \"_\" pour les espaces)\nMessage : ");
  25.             lire(messagesNonCrypte,TAILLE_MAX);
  26.             //scanf("%s",messagesNonCrypte);
  27.             printf("Quelle est la cle ?\nCle : ");
  28.             //scanf("%d",&cle);
  29.             cle = lireLong();
  30.             Chiffrement(messagesNonCrypte,messagesCrypte,cle);
  31.             Save(messagesNonCrypte,messagesCrypte,cle);
  32.             printf("Le message crypte est : %s",messagesCrypte);
  33.         }
  34.         else if(choix == 2) //Dechiffrement
  35.         {
  36.              printf("Quelle est le message ? (utiliser \"_\" pour les espaces)\nMessage : ");
  37.             //scanf("%s",messagesCrypte);
  38.             lire(messagesCrypte,TAILLE_MAX);
  39.             printf("Quelle est la cle ?\nCle : ");
  40.             //scanf("%d",&cle);
  41.             cle = lireLong();
  42.             Dechiffrement(messagesCrypte,messagesNonCrypte,cle);
  43.             Save(messagesNonCrypte,messagesCrypte,cle);
  44.             printf("Le message decrypte est : %s",messagesNonCrypte);
  45.         }
  46.         else if(choix == 3) //SAVE
  47.         {
  48.             AfficherSave();
  49.         }
  50.         else if(choix == 4) //EXIT
  51.         {
  52.             goto FIN;
  53.         }
  54.         else
  55.         {
  56.             printf("Erreur mauvais choix\n");
  57.         }
  58.  
  59.     }
  60.     FIN:
  61.     return 0;
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement