Beispiel #1
0
 public static string affineEncrypt(int a, int b, string input)
 {
     //E(a,b,x)=a*x+b (mod 26)
     if (CryptographyUtils.gcd(a, CryptographyUtils.AlphabetLength) != 1)
     {
         Console.WriteLine("Niepoprawny klucz do enkrypcji");
         return(null);
     }
     return(CryptographyUtils.encrypt(a, b, input));
 }
Beispiel #2
0
 public static bool checkAffineKey(int a, int range)
 {
     if ((CryptographyUtils.gcd(a, range) == 1) && ((a * (CryptographyUtils.oppositeModulo(a, range)) % range) == 1))
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }