Esempio n. 1
0
        public override string Decryption(string ciphertext, int start = 'A')
        {
            var result = ciphertext.ToCharArray().Select(c => c - 'A').ToArray();

            for (int i = 0; i < result.Length; i++)
            {
                var modKey = new ModularArithmetic(PrivateKey.Count());
                var mod26  = new ModularArithmetic(26);
                result[i] = (int)mod26.PositiveMod(result[i] - PrivateKey.ElementAt((int)modKey.PositiveMod(i)));
            }
            return(new String(result.Select(num => Convert.ToChar(num + start)).ToArray()));
        }
Esempio n. 2
0
 public Solution()
 {
     //Because potential numbers might be very big we will use modular arithemtic
     _modularArithmetic = new ModularArithmetic(_modulus);
 }
Esempio n. 3
0
 public Solution()
 {
     //Because potential numbers might be very big we will use modular arithmetic
     _modularArithmetic = new ModularArithmetic(_modulus);
 }
Esempio n. 4
0
 public Solution()
 {
     //Because potential numbers might be very big (worst case 1000000!) we will use modular arithemtic
     _modularArithmetic = new ModularArithmetic(1410000017);
 }
Esempio n. 5
0
 public AffineCipher(IEnumerable <BigInteger> key = null)
 {
     PrivateKey = key;
     Mod        = new ModularArithmetic(26);
 }
Esempio n. 6
0
 public Solution()
 {
     //Because potential numbers might be very big (worst case 1000000!) we will use modular arithemtic
     _modularArithmetic = new ModularArithmetic(1410000017);
 }