// ------------------------------------------------------------------------------------------------------------------
        public HomophonicSolver(NGrams nGrams) : base(nGrams)
        {
            Random rnd = new Random(Guid.NewGuid().GetHashCode());

            // Letter frequencies for common english plaintexts
            float[] letterFrequencies =
            {
                8.167f,     // a
                1.492f,     // b
                2.782f,     // c
                4.253f,     // d
                12.703f,    // e
                2.228f,     // f
                2.015f,     // g
                6.094f,     // h
                6.966f,     // i
                0.153f,     // j
                0.772f,     // k
                4.025f,     // l
                2.406f,     // m
                6.749f,     // n
                7.507f,     // o
                1.929f,     // p
                0.095f,     // q
                5.987f,     // r
                6.327f,     // s
                9.056f,     // t
                2.758f,     // u
                0.978f,     // v
                2.360f,     // w
                0.150f,     // x
                1.974f,     // y
                0.074f      // z
            };

            // Create a table which contains the numbers 0-25 (A-Z) according to
            // the letter frequencies.
            // e.g. 816 times "0" ("A"), 1270 times "4" ("E") and so on.
            for (int i = 0; i < letterFrequencies.Length; i++)
            {
                for (float k = 0; k < letterFrequencies[i] * 100.0f; k++)
                {
                    letterFrequenciesEnglish.Add(i);
                }
            }

            letterFrequencyTableSize = letterFrequenciesEnglish.Count;
        }
Exemplo n.º 2
0
 // ------------------------------------------------------------------------------------------------------------------
 #region Methods
 public SubstitutionSolverBase(NGrams nGrams)
 {
     this.nGrams = nGrams;
 }