Ejemplo n.º 1
0
 public Set2()
 {
     _ecbUtilities = new EcbUtilities();
     _stringUtilities = new StringUtilities();
     _hexadecimalUtilities = new HexadecimalUtilities();
 }
Ejemplo n.º 2
0
        /*
         * Detect single-character XOR
         * One of the 60-character strings in this file has been encrypted by single-character XOR.
         * Find it.
         *
         * (Your code from #3 should help.)
         *
         */
        public string XorCipher(string[] hexadecimalStringArray)
        {
            double score = 0;
            double highestScore = 0;

            string decipheredString = String.Empty;
            string highestScoringString = String.Empty;

            StringUtilities stringScorer = new StringUtilities();

            foreach (string hexadecimalString in hexadecimalStringArray)
            {
                decipheredString = XorCipher(hexadecimalString);
                score = stringScorer.ScoreStringByLetter(decipheredString);

                if (score > highestScore)
                {
                    highestScore = score;
                    highestScoringString = decipheredString;
                }
            }

            return highestScoringString;
        }