System.Security.Cryptography.CryptoStream.Clear C# (CSharp) Method

Clear() public method

public Clear ( ) : void
return void
        public void Clear()
        {
            Close();
        }        

Usage Example

Ejemplo n.º 1
0
        public void CreyptoStreamExample()
        {
            var algorithm = SymmetricAlgorithm.Create();
            //algorithm.GenerateKey();
            //algorithm.GenerateIV();

            using(var file = File.Create(@".\key.txt"))
            {
              //  file.Write(algorithm.Key, 0, algorithm.Key.Length);
            }

            using (var file = File.Create(@".\IV.txt"))
            {
                //file.Write(algorithm.IV, 0, algorithm.IV.Length);
            }

            algorithm.Key = KeyAndIV;
            algorithm.IV = KeyAndIV;

            var encryptor = algorithm.CreateEncryptor();
            algorithm.Padding = PaddingMode.None;

            using(var inputStream = new FileStream(@".\EncryptedFile.txt", FileMode.OpenOrCreate))
            using(var cryptoStream = new CryptoStream(inputStream, encryptor, CryptoStreamMode.Write))
            {
                var input = Encoding.UTF8.GetBytes(SecretText);
                cryptoStream.Write(input, 0, input.Length);
                cryptoStream.Clear();
            }
        }
All Usage Examples Of System.Security.Cryptography.CryptoStream::Clear