CryptoStream Constructors

Definition

Overloads

CryptoStream(Stream, ICryptoTransform, CryptoStreamMode)

Initializes a new instance of the CryptoStream class with a target data stream, the transformation to use, and the mode of the stream.

CryptoStream(Stream, ICryptoTransform, CryptoStreamMode, Boolean)

Initializes a new instance of the CryptoStream class.

CryptoStream(Stream, ICryptoTransform, CryptoStreamMode)

Source:
CryptoStream.cs
Source:
CryptoStream.cs
Source:
CryptoStream.cs

Initializes a new instance of the CryptoStream class with a target data stream, the transformation to use, and the mode of the stream.

C#
public CryptoStream(System.IO.Stream stream, System.Security.Cryptography.ICryptoTransform transform, System.Security.Cryptography.CryptoStreamMode mode);

Parameters

stream
Stream

The stream on which to perform the cryptographic transformation.

transform
ICryptoTransform

The cryptographic transformation that is to be performed on the stream.

mode
CryptoStreamMode

One of the CryptoStreamMode values.

Exceptions

stream is invalid.

Remarks

Any object that derives from Stream can be passed into the stream parameter. Any object that implements ICryptoTransform (such as HashAlgorithm) can be passed into the transform parameter.

See also

Applies to

.NET 10 and other versions
Product Versions
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 1.3, 1.4, 1.6, 2.0, 2.1

CryptoStream(Stream, ICryptoTransform, CryptoStreamMode, Boolean)

Source:
CryptoStream.cs
Source:
CryptoStream.cs
Source:
CryptoStream.cs

Initializes a new instance of the CryptoStream class.

C#
public CryptoStream(System.IO.Stream stream, System.Security.Cryptography.ICryptoTransform transform, System.Security.Cryptography.CryptoStreamMode mode, bool leaveOpen);

Parameters

stream
Stream

The stream on which to perform the cryptographic transformation.

transform
ICryptoTransform

The cryptographic transformation that is to be performed on the stream.

mode
CryptoStreamMode

The mode of the stream.

leaveOpen
Boolean

true to not close the underlying stream when the CryptoStream object is disposed; otherwise, false.

Exceptions

mode is invalid.

Applies to

.NET 10 and other versions
Product Versions
.NET Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 4.7.2, 4.8, 4.8.1
.NET Standard 2.1