public override void Execute() { cipherTextParser.Execute(); using (var provider = new RijndaelManaged()) { var transformer = cryptographicTransformerFactory.CreateCryptographicTransformer(provider, cipherTextParser.Cipher.Message, key, cipherTextParser.Cipher.InitialisationVector); transformer.Execute(); Output = Encoding.UTF8.GetString(transformer.Cipher); } }
public override void Execute() { var initialisationVector = new byte[16]; using (var rng = new RNGCryptoServiceProvider()) rng.GetBytes(initialisationVector); byte[] inputCipher; using (var provider = new RijndaelManaged()) { var transformer = cryptographicTransformerFactory.CreateCryptographicTransformer(provider, input, key, initialisationVector); transformer.Execute(); inputCipher = transformer.Cipher; } var cipher = new byte[initialisationVector.Length + inputCipher.Length]; Buffer.BlockCopy(initialisationVector, 0, cipher, 0, initialisationVector.Length); Buffer.BlockCopy(inputCipher, 0, cipher, initialisationVector.Length, inputCipher.Length); Output = Convert.ToBase64String(cipher); }