nsajob.blogg.se

Playfair cipher program code
Playfair cipher program code












playfair cipher program code playfair cipher program code

Public static char ReturnSoln(char child, string cipher, double bookDigraph)

playfair cipher program code playfair cipher program code

100000000) //number should be value of parentScore which indicates a solution has been foundĬheckDoneCrack(cipher, parent) //asks user whether solution is correctįile.WriteAllText("crack.sol", decryptedText) Ĭonsole.WriteLine("The decrypted text has been saved as: crack.sol.") Ĭatch(Exception e) //exteption handler e handles exceptionsĬonsole.WriteLine("There has been an error!") Ĭonsole.WriteLine("Error:" + e.Message) //prints exception onto consoleĬonsole.WriteLine(Convert.ToChar(7)) Console.WriteLine(Convert.ToChar(7)) //Sound to signify end of program Temp = SwapSpecificRow(row_a, row_b, child) //Swap rows back String decryptedText = Decryption.Result(cipher, temp) //generates decoded message to be used to create digraphĭouble decryptedTextDigraph = digraphCipher.NormalisedPairCount(decryptedText) //creates digraph to be used to find scoreĭouble tempScore = Result.FinalScoreMult(decryptedTextDigraph, bookDigraph) //calculates the score of child to be used to analyse the quality of the temp keyĭecryptedText = Decryption.Result(cipher, child) //generates decoded message to be used to create digraphĭecryptedTextDigraph = digraphCipher.NormalisedPairCount(decryptedText) //creates digraph to be used to find scoreĭouble childScore = Result.FinalScoreMult(decryptedTextDigraph, bookDigraph) //calculates the score of child to be used to analyse the quality of the child keyĬhildScore = tempScore //childScore is always the highest score Public static char FindBestRow(char child, string cipher, double bookDigraph)Ĭhar temp = Key.RandKey(Key.randAlphabet()) * and performs every possible row swap, and returns Temp = SwapSpecificCol(col_a, col_b, child) //Swap columns backĬhild = temp //child always set to the best score Public static char FindBestCol(char child, string cipher, double bookDigraph)ĭouble childScore = Result.FinalScoreMult(digraphCipher.NormalisedPairCount(Decryption.Result(cipher, child)), bookDigraph) Ĭhar temp = Key.RandKey(Key.randAlphabet()) //Initialises random new keyĬhildScore = tempScore //childScore is always the highest score in this method * the one which corresponds to the highest score*/ * and performs every possible column swap, and returns *this method takes in a key and the cipher text,














Playfair cipher program code