fork download
  1.  
  2.  
  3. // CHALLENGE PAR Ryscrow - http://w...content-available-to-author-only...e.org/fr/Challenges/Cryptanalyse/Decomposition-pixelisee
  4. // --------------------------------------------------------------------------------------------------------------
  5.  
  6.  
  7. #include <stdio.h>
  8. #include <stdlib.h>
  9.  
  10.  
  11. void Afficher(char car, unsigned int nb)
  12. {
  13. unsigned int c = 0;
  14. char pixel;
  15.  
  16. if (car == '0') { pixel = '\x20'; } // Voir une table ASCII - correspond à un espace (pixel noir)
  17. else { pixel = '\xdb'; } // correspond à un rectangle plein (pixel blanc)
  18.  
  19. while (c != nb)
  20. {
  21. printf("%c", pixel);
  22. c++;
  23. }
  24.  
  25. }
  26.  
  27. //------------------------------------------------
  28.  
  29. int Analyser()
  30. {
  31. FILE *hFichier = fopen("decomp_pixel.txt", "r");
  32. char car = 0, nb1 = 0, nb2 = 0, curseur;
  33.  
  34. if (hFichier == NULL)
  35. {
  36. printf("\t>Impossible de trouver le fichier\n\n");
  37. return 0;
  38. }
  39. printf("\n");
  40.  
  41. while (fread(&car, 1, sizeof(char), hFichier) != 0)
  42. {
  43. if (car == '\n') { fread(&curseur, 1, 1, hFichier); printf("\n"); continue; } // Fin de ligne
  44. if (car == '+') { continue; }
  45. fread(&curseur, 1, 1, hFichier); // On déplace le curseur de 1 caractère
  46. fread(&nb1, 1, sizeof(char), hFichier); // On lit les deux caractères suivant le 'x'
  47. fread(&nb2, 1, sizeof(char), hFichier); // Le second peut être un chiffre, un '+' ou un saut de ligne
  48. if (nb2 == '+') { Afficher(car, nb1 - 48); } // On soustrait 48 pour obtenir le chiffre et non le caractère ASCII
  49. else if (nb2 == '\n') { printf("\n"); fread(&curseur, 1, 1, hFichier); }
  50. else { Afficher(car, (nb1-48)*10 + (nb2-48)); } // S'il s'agit d'un chiffre
  51.  
  52. }
  53.  
  54. printf("\n\n\n\n");
  55. fclose(hFichier);
  56.  
  57. }
  58.  
  59.  
  60. //------------------------------------------------
  61.  
  62. int main(int argc, char *argv[])
  63.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