public void decrypter(object j, string file_name) { ReceptionSTGClient rSTG = new ReceptionSTGClient(); //paramDelegate oDLG = new paramDelegate(rSTG.sendToQueue); int k = (int)j; int start = this.starters[k]; int operation = this.operations[k]; for (int i = start; i < operation; i++) { string solution = EncryptOrDecrypt(this.txt_tab, i.ToString()); //Console.WriteLine("Décryptage avec la clé :" + i); solution = CleanInvalidXmlChars(solution); string[] solution_split = solution.Split(new char[] { ' ' }); // solution_split[0].Length < 50 // solution_split[0].Contains('@') if (solution_split.Length > 1 || solution_split[0].Length < 50) { rSTG.sendToQueue(solution, file_name, i.ToString(), true); envoi++; } //Console.WriteLine("apres send : " + sw.ElapsedMilliseconds.ToString()); if (GlobalVariables.clientStop) { GlobalVariables.clientStop = false; break; } else if (GlobalVariables.cleTrouve) { break; } else if (GlobalVariables.finTraitement) { GlobalVariables.finTraitement = false; break; } //Console.WriteLine("fin boucle : " + sw.ElapsedMilliseconds.ToString()); //Console.WriteLine(txt_decrypted); } }
public STG Execute(STG oSTG) { Stopwatch sw2 = new Stopwatch(); sw2.Start(); Hashtable files = (Hashtable) oSTG.files; int sampleSize = (int)oSTG.GetData("sampleSize"); bool useSample = true; if (sampleSize < 1) { useSample = false; } ReceptionSTGClient rSTG = new ReceptionSTGClient(); foreach (DictionaryEntry key in files) { Stopwatch sw = new Stopwatch(); sw.Start(); //Console.WriteLine("key : "+key.Key/* + " - value :" + key.Value*/); string texte = key.Value.ToString(); string echantillon; if (texte.Length > sampleSize && useSample) { echantillon = texte.Substring(0, sampleSize); } else { echantillon = texte; } int taille = echantillon.Length; uint[] txt_tab = new uint[taille]; for (int j = 0; j < taille; j++) { txt_tab[j] = (uint)echantillon[j]; } Console.WriteLine("début de l'envoi des messages : "); Helper help = new Helper(); // on lit le fichier help.Txt_tab = txt_tab; // On compte le nombre de processeur : int heart = Environment.ProcessorCount; int keyNumber = 10000; string file_name = key.Key.ToString(); //On complete les tableau de start et operations help.calculOperation(heart, keyNumber); // Création du delegate de traitement : paramDelegate dlg = new paramDelegate(help.decrypter); // ON commence le traitement sur les 10 000 clés Parallel.For(0, heart, i => { help.decrypter(i, file_name); }); sw.Stop(); Console.WriteLine("messages envoyés : " + help.Envoi + " en " + sw.Elapsed + " secondes"); if (GlobalVariables.cleTrouve) { break; } } if (GlobalVariables.cleTrouve) { int nb_files = 0; foreach (DictionaryEntry key in files) { string texte = key.Value.ToString(); int taille = texte.Length; uint[] txt_tab = new uint[taille]; for (int j = 0; j < taille; j++) { txt_tab[j] = (uint)texte[j]; } string txt = EncryptOrDecrypt(txt_tab, GlobalVariables.cle); txt = CleanInvalidXmlChars(txt); rSTG.sendToQueue(txt, key.Key.ToString(), GlobalVariables.cle, false); nb_files++; //Console.WriteLine(txt); //Console.WriteLine("l'email trouve est" + GlobalVariables.mail); } while (GlobalVariables.nb_callback < nb_files) { System.Threading.Thread.Sleep(500); } oSTG.files.Clear(); oSTG.SetData("cle", GlobalVariables.cle); oSTG.SetData("mail", GlobalVariables.mail); oSTG.files = GlobalVariables.files; } sw2.Stop(); Console.WriteLine("Temps de traitement total : " + sw2.Elapsed.ToString()); return oSTG; }