Beispiel #1
0
 public void UpdateInverseNumbersList()
 {
     foreach (int num in mNumbersList)
     {
         mInverseNumbers.Add(CalcUtilities.FindInverseNumber(num, mNumbersList, m));
     }
 }
Beispiel #2
0
 public override void UpdateNumbersList()
 {
     for (int i = 0; i < m; ++i)
     {
         if (CalcUtilities.GCD(i, m) == 1)
         {
             mNumbersList.Add(i);
         }
     }
 }
Beispiel #3
0
        public static string DecipherString(string encryptedString, int keyA, int keyB,
                                            MultGroup multGroup, AddGroup addGroup)
        {
            StringBuilder decipheredString = new StringBuilder();

            foreach (char ch in encryptedString)
            {
                int y = CalcUtilities.GetEnglishLetterIndex(ch);
                int minusOperationResult = addGroup.GetNegativeNumber((y - keyB));
                int inverseNumber        = multGroup.GetInverseNumber(keyA);
                int x = (minusOperationResult * inverseNumber) % multGroup.Mod;
                x = x <= 0 ? -x : x;     // Makes X positive.
                decipheredString.Append(CalcUtilities.GetUpperEnglishLetterByIndex(x));
            }

            return(decipheredString.ToString());
        }
Beispiel #4
0
 public int GetInverseNumber(int number)
 {
     return(CalcUtilities.FindInverseNumber(number, mNumbersList, m));
 }