usingSystem;usingSystem.Collections.Generic;usingSystem.IO;usingSystem.Net.Sockets;usingDistributedPasswordCracker.Client.Models;namespaceDistributedPasswordCracker.Client{classProgram{constintNumberOfTasks=5;privatestaticStreamReadersr;privatestaticStreamWritersw;staticvoidMain(string[]args){Console.Write("Connecting to server... ");TcpClientclientSocket=newTcpClient("127.0.0.1",6789);NetworkStreamns=clientSocket.GetStream();Console.Write("OK\n");sr=newStreamReader(ns);sw=newStreamWriter(ns);sw.AutoFlush=true;Console.Write("Getting data from the server... ");stringdata=GetData();if(data!="")Console.Write("OK\n");Console.Write("Parsing data... ");stringdictionary=ParseData(data);if(dictionary!="")Console.Write("OK\n");Console.Write("Splitting dictionary... ");string[,]splitDictionary=SplitDictionary(dictionary);if(splitDictionary[0,0]!="")Console.Write("OK\n");List<UserInfoClearText>result=newList<UserInfoClearText>();for(inti=0;i<NumberOfTasks;i++){Console.Write("Running task no."+(i+1)+"...\n");introwLength=splitDictionary.GetLength(1);string[]chunk=newstring[rowLength];for(intj=0;j<rowLength;j++)chunk[j]=splitDictionary[i,j];result=DecryptPassword(chunk);}if(result.Count!=0){sw.WriteLine(result[0].ToString());}else{sw.WriteLine("Nothing Found!");}}privatestaticstringGetData(){stringdata="";while(true){stringmessage=sr.ReadLine();if(message!="")data+=message+"\n";elsebreak;}returndata;}privatestaticstringParseData(stringdata){varsplitData=data.Split('\n');if(splitData[0]=="DPCP 1.0"){splitData[1]=splitData[1].Replace('|','\n');File.WriteAllText("passwords.txt",splitData[1]);File.WriteAllText("dictionary.txt",splitData[2]);}returnsplitData[2];}privatestaticstring[,]SplitDictionary(stringdictionary){string[]dicWords=dictionary.Split('|');intdicWordsLength=dicWords.Length;string[,]splitDictionary=newstring[NumberOfTasks,dicWordsLength/NumberOfTasks];intoffset=0;intj=0;for(inti=0;i<NumberOfTasks;i++){while(j<dicWordsLength/NumberOfTasks){splitDictionary[i,j]=dicWords[j+offset];j++;}offset+=dicWordsLength/NumberOfTasks;j=0;}returnsplitDictionary;}privatestaticList<UserInfoClearText>DecryptPassword(string[]dictionary){Crackingcracker=newCracking();varresult=cracker.RunCracking(dictionary);returnresult;}}}