IPB

Bienvenue invité ( Connexion | Inscription )

 
Reply to this topicStart new topic
> Crypto C++, Crypter un texte en image
neibaf
posté May 2 2006, 14:49
Message #1


J'apprends, j'apprends...
**

Groupe : Members
Messages : 21
Inscrit : 9-December 04
Lieu : Ferdrupt, Vosges
Membre no 730



Voilà, bonjour, je voudrais crypter du texte pour m'entrainer à la crypto, seulement mon idée était de prendre la valeur ASCII du caractère, et en faire un pixel... L'ennui c'est cette transformation, comment fait-on en C pour créer sa propre image BITMAP(256 Couleurs) ou .raw?

Je suppose que je m'engage dans un truc bien compliqué à réaliser mais ça pourrait être bien.
Go to the top of the page
 
+Quote Post
GROS N@Z
posté May 4 2006, 21:19
Message #2


Team ADNPC.net
Icône de groupe

Groupe : Admin ADNPC
Messages : 368
Inscrit : 23-July 03
Membre no 113



faut coder l'entete et après t as ton contenu biensur. Pour l'entete tu as toutes les infos ici :

http://www.commentcamarche.net/video/format-bmp.php3

je l'ai fait en tp en cours (pour l'entete d'un fichier bitmap) mais je crois que je ne l'ai pas là...

En gros tu fais une structure entete dans laquelle tu as toutes les infos de l entete

tu cré un fichier (fopen, etc...) avec un pointeur dessus et tu insere ta structure puis vient le corps de l image....


--------------------
Go to the top of the page
 
+Quote Post
Maxim'
posté May 6 2006, 12:05
Message #3


Team ADNPC.net
Icône de groupe

Groupe : Admin ADNPC
Messages : 658
Inscrit : 13-April 04
Lieu : Grenoble (France)
Membre no 538



Mais c'est qu'il commence à s'y connaitre le petit !

;-)


--------------------
Un clavier azerty en vaut deux.
ADNPC.net - Fréquence News - Logiciel sur mesure
Go to the top of the page
 
+Quote Post
GROS N@Z
posté May 6 2006, 13:28
Message #4


Team ADNPC.net
Icône de groupe

Groupe : Admin ADNPC
Messages : 368
Inscrit : 23-July 03
Membre no 113



lol :p


--------------------
Go to the top of the page
 
+Quote Post
neibaf
posté May 10 2006, 20:17
Message #5


J'apprends, j'apprends...
**

Groupe : Members
Messages : 21
Inscrit : 9-December 04
Lieu : Ferdrupt, Vosges
Membre no 730



En fait c'est pas les Header qui me dérangent... Enfin un peu mais c'est pas le plus grave... C'est le comment qu'on fait pour "Ecrire" un Pixel ? C'est surtout ça le gros ennui ( parceque au pire... je prends un fichier .raw et je n'ai plus de header... Enfin bref... Pour ça vous savez?)
Go to the top of the page
 
+Quote Post
GROS N@Z
posté May 11 2006, 12:39
Message #6


Team ADNPC.net
Icône de groupe

Groupe : Admin ADNPC
Messages : 368
Inscrit : 23-July 03
Membre no 113



Voila pour l entete

Code
#include <stdio.h>
#include <stdlib.h>
#include <iostream.h>

typedef struct      /* définition d'une structure qui contiendra les informations de l'entete */
{
short signature;
long size_file;
long champ_reserve;
long offset_img;
long size_head;
long larg_img;
long haut_img;
short nb_plans;
short cod_couleur;
long compress;
long size_img;
long reso_hori;
long reso_vert;
long nb_couleur;
long couleur_imp;
}header;


void main(void)
{
   header var; /* variable de type header */
   FILE* pfichier;
    FILE* pfichier2;
   header*ptr = &var;
   int cpt, temp;

   var.larg_img = 1024; /*Largeur de l'image en pixels*/
   var.haut_img = 768;  /*hauteur de l'image en pixels*/
   var.signature = 0x424D; /*signature : c'est un fichier .bmp */
    var.size_head = 0x28;  /*taille de l'entete de l'image : Windows 3.1x, 95, NT, ...*/
   var.cod_couleur = 24; /* profondeur de codage de la couleur : 24 bits*/
   var.compress = 0; /* Pas de compression */
   var.couleur_imp = 0; /* Pas de couleurs importantes */
   var.nb_plans = 0; /* 1 seul plan */
    var.reso_hori = 1024;
   var.reso_vert = 768;
   var.offset_img = 0x36;
   var.size_file =2359350;

   pfichier = fopen("H:\\language_C\\TP13_2\\dest.bmp","w"); /* On ouvre un fichier nommé dest.bmp pour écrire */
   pfichier2=fopen("H:\\language_C\\TP13_2\\source.dat","r"); /* On ouvre un fichier nommé source.dat pour lire */

   if((pfichier!=NULL) && (pfichier2!=NULL))
   {
       fseek(pfichier2,0,2);
      var.size_img = ftell(pfichier2);
      fwrite(&var,sizeof(header),1,pfichier);

      for(cpt=0; cpt<((long) 2359296);cpt++)
      {
      temp = fgetc(pfichier2);
      fputc(temp,pfichier);
      }
   }
   fclose(pfichier);
   fclose(pfichier2);
}


Pour ce qui est du contenu (dans ce cas, le fichier.dat), nous c était déjà tout fait donc on a pas vu...
Ce sont des valeurs hexa mais la signification vraiment je ne sais pas...


--------------------
Go to the top of the page
 
+Quote Post
N.Master
posté Jun 11 2006, 15:02
Message #7


Je commence à maitriser...
***

Groupe : Members
Messages : 81
Inscrit : 2-January 05
Lieu : dans l'ain, à 1h de Lyon
Membre no 742



c'est original de vouloir crypter du texte dans une image, mais il y a plus simple :
La méthode la plus simple (pour ne pas dire simpliste) que je connaisse pour crypter, c'est de faire un cryptage en xor .
le princippe c'est

A xor B = C
et
C xor B = A

si A est le texte, et B la clé, tu obtiens le texte crypté C
ensuite, a partir du texte crypté, tu refais un coup de xor, et tu obtiens de nouveau A

Bon, là ce n'est que le concept simplifié a l'extrème, mais c'est a ma connaissance une des méthodes les plus simples.


--------------------
un bon moddeur n'est jamais totalement satisfait
Go to the top of the page
 
+Quote Post
Ljunki
posté Oct 13 2009, 09:22
Message #8


Où suis-je ?


Groupe : Members
Messages : 4
Inscrit : 13-October 09
Membre no 5 219



Rich Man

Grandfather was a philosopher, and like a lot of philosophers, I guess, he was a mild-mannered man who was always ready to admit that there are two sides to every question. So when people got to arguing with him, or around him, about things that they got heated up and illogical about, like politics and religion,1 he would tell this story that Doc Eaton told him one day up on the Hill. (Wow Power Leveling)

??It happened a long time ago, when the town wasn't all steel and concrete and automobiles; when you could still hear the whir of a lawn mower without taking a streetcar out to the suburbs, and still see a horse lazily switching at the flies on his flanks under almost any sycamore tree.2 The Forest City had a lot of trees in those days.

??And it had a lot of people that didn't always see eye to eye,3 like a lot of other cities. And it had a rich man, like almost every other town. And this rich man was a pillar in the Baptist Church;4 and people didn't see eye to eye about him, either.

??There were those—and Grandfather's eyes twinkled when he said it—that claimed the rich man was an old hypocrite5, that he was ruthless in his business dealings, that he was so tightfisted he wouldn't spend a nickel to see an earthquake,6 that when he went to church on Sunday morning he was almost as important as God to a lot of people. world of warcraft gold

??Then there was the other school of thought7. It asserted that just because a man had made money under conditions as they existed was no reason to call him a lot of hard names.8 In fact, they asserted stoutly, the people that called him names were merely envious of his success9. They maintained he went to church not because he was a sanctimonious old fraud10 but because he was at heart, and for all his money, a simple, deeply religious man.

??It was while these two groups were hot at it that the rich man gave a party. Well, it wasn't exactly a party, Grandfather would explain. It was more like a shower for the pastor of the church.11 One group of parishioners saw in their invitation nothing but a kindly, neighborly gesture. The other just said it showed how miserly the old buzzard was12—getting other people to do what he could have done a thousand times over without feeling it a mite.13

??Grandfather said even then he had the sneaking feeling that the rich man wasn't so insulated and isolated by his money14 that he didn't know what people were saying about him, and that was the real reason he gave the party.

??But both sides of the question went to the party. A lot of them were pretty curious about the inside of a rich man's home. world of warcraft gold

??They brought offerings for the pastor, as they were requested. Some people brought apples, and others brought sides of bacon and onions and other homey old-fashioned things like that15. But nobody was really much interested in what the other guests brought. They were all waiting for one thing. What would the rich man bring out? Even Doc Eaton, the preacher, according to Grandfather, couldn't help wondering about what was coming. You could feel the undercurrent of suspense.

??And then the rich man16 brought out his offering.

??It was a bushel of potatoes.17 They were nice potatoes, extra large and scrubbed white and clean. But still and all, they were only a bushel of potatoes that anybody could buy in the Old Market for a lot less than a dollar.

??Well, sir, Grandfather chuckled, you could practically see what people were thinking. They were the people who were saying to themselves and to everybody else, "Well, what did I tell you??And then there were those who made it perfectly plain that they thought it was mighty tactful of their host not to make an ostentatious parade of his money18 before a lot of neighbors and friends. cd keys

??But the host went around as if he didn't notice anything, though Grandfather always insisted that he detected a little twinkle in the rich man's eyes as he shook hands with all his fellow parishioners and wished them good night.

??The preacher toted19 his gifts into his house, and just because they had been the center of interest, so to speak, he picked one of the big white potatoes out of the basket. Then he noticed that one end of the potato had been opened. He investigated, and discovered that a silver dollar had been neatly inserted through the opening. He examined every potato in that bushel basket, and there was a silver dollar in every single one of them.

??At this point Grandfather usually sat back and plucked benignly at his white beard20 and smiled. Then he'd turn philosopher and say:

??"It takes an almighty pile of gall21 for a man to sit up and say what is going on in another man's mind, don't22 it? I mean one way or another. When Doc Eaton told me that story he didn't bother to point out any moral. By the way, he don't do any preaching any more. He's been a congressman from New Jersey for years and years. But I guess the story has a moral, all right. Always sort of tickled23 me, like it must have tickled Doc's rich parishioner." Aion gold

??"The New Testament says it is easier for a camel to go through the eye of a needle than for a rich man to enter the kingdom of God.24 Well, I ain't saying it isn't true. But I am saying this: It took John D. Rockefeller to put a silver dollar through the eye of a potato in order that a lot of people could have some food for thought."
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic
1 utilisateur(s) sur ce sujet (1 invité(s) et 0 utilisateur(s) anonyme(s))
0 membre(s) :

 



Version bas débit Nous sommes le : 22 October 2019 - 07:47