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())); }
public Solution() { //Because potential numbers might be very big we will use modular arithemtic _modularArithmetic = new ModularArithmetic(_modulus); }
public Solution() { //Because potential numbers might be very big we will use modular arithmetic _modularArithmetic = new ModularArithmetic(_modulus); }
public Solution() { //Because potential numbers might be very big (worst case 1000000!) we will use modular arithemtic _modularArithmetic = new ModularArithmetic(1410000017); }
public AffineCipher(IEnumerable <BigInteger> key = null) { PrivateKey = key; Mod = new ModularArithmetic(26); }