public CalculationResult Calculate(string input) { var result = CalculationResult.StartCalculations (input, _monoAlphabet, EncoderType.Trithemius, _codingType, out IMonoAlphabet alpha); IAlphabetEncoder trithemius = EncoderFactory .CreateEncoder(EncoderType.Trithemius) .SetMonoAlphabet(alpha) .Configure(_key, (Func <int, int>)_map); var output = _codingType == CodingType.Encoding ? trithemius.Encode(input) : trithemius.Decode(input); return(result.WithKey(_key.ToString()).WithFunction(_map).EndCalculations(output)); }
public CalculationResult Calculate(string input) { var result = CalculationResult.StartCalculations (input, _monoAlphabet, EncoderType.Caesar, _codingType, out IMonoAlphabet alpha); IAlphabetEncoder caesar = EncoderFactory .CreateEncoder(EncoderType.Caesar) .SetMonoAlphabet(alpha) .Configure(_key); var output = _codingType == CodingType.Encoding ? caesar.Encode(input) : caesar.Decode(input); return(result.WithKey(_key.ToString()).EndCalculations(output)); }