Пример #1
0
        private void MakeDycrypt()
        {

            var autofc = new Autofc();
            _container = autofc.Container;
            var currentAlgorithm = _container.ResolveKeyed<SymmetricAlgorithm>(_algorithm);
            currentAlgorithm.Padding = PaddingMode.None;
            //var currentAlgorithm = new AesCryptoServiceProvider {Padding = PaddingMode.None};
            ReadKey();
            var decryptor = currentAlgorithm.CreateDecryptor(_key, _iv);
            using (var cryptoStream = new CryptoStream(_reader, decryptor, CryptoStreamMode.Read))
            {
                cryptoStream.CopyTo(_writer);
            }
            _reader.Dispose();
            _writer.Dispose();
        }
Пример #2
0
        private void MakeEncrypt()
        {
            var autofc = new Autofc();
            _container = autofc.Container;
            var currentAlgorithm = _container.ResolveKeyed<SymmetricAlgorithm>(_algorithm);
            //var currentAlgorithm = new AesCryptoServiceProvider();
            _key = currentAlgorithm.Key;
            _iv = currentAlgorithm.IV;
            WriteKey();
            var encryptor = currentAlgorithm.CreateEncryptor(_key, _iv);
            using (var cryptoStream = new CryptoStream(_writer, encryptor, CryptoStreamMode.Write))
            {
                _reader.CopyTo(cryptoStream);
            }
            _reader.Dispose();
            _writer.Dispose();

        }