Class DecryptStream
A wrapper stream that decrypts the base stream as it is being read.
public abstract class DecryptStream : WrapperStream, IDisposable, IAsyncDisposable
- Inheritance
-
DecryptStream
- Implements
- Derived
- Inherited Members
Constructors
DecryptStream(Stream)
Initializes an DecryptStream with an decryption algorithm and a base stream.
protected DecryptStream(Stream baseStream)
Parameters
baseStream
StreamStream to perform encryption on..
Properties
Algorithm
protected IDecryptionWrapper Algorithm { get; set; }
Property Value
CanSeek
Gets a value indicating whether the current stream supports seeking. DecryptStream does not support seeking, this will always be false.
public override bool CanSeek { get; }
Property Value
CryptoStream
protected CryptoStream CryptoStream { get; set; }
Property Value
Position
Gets or sets the position within the current stream. DecryptStream does not support seeking, attempting to set Position will throw NotSupportedException.
public override long Position { get; set; }
Property Value
Methods
Read(byte[], int, int)
Reads a sequence of bytes from the current stream and advances the position within the stream by the number of bytes read.
public override int Read(byte[] buffer, int offset, int count)
Parameters
buffer
byte[]An array of bytes. When this method returns, the buffer contains the specified byte array with the values between offset and (offset + count - 1) replaced by the bytes read from the current source.
offset
intThe zero-based byte offset in buffer at which to begin storing the data read from the current stream.
count
intThe maximum number of bytes to be read from the current stream.
Returns
- int
The total number of bytes read into the buffer. This can be less than the number of bytes requested if that many bytes are not currently available, or zero (0) if the end of the stream has been reached.
ReadAsync(byte[], int, int, CancellationToken)
Asynchronously reads a sequence of bytes from the current stream and advances the position within the stream by the number of bytes read.
public override Task<int> ReadAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken)
Parameters
buffer
byte[]An array of bytes. When this method returns, the buffer contains the specified byte array with the values between offset and (offset + count - 1) replaced by the bytes read from the current source.
offset
intThe zero-based byte offset in buffer at which to begin storing the data read from the current stream.
count
intThe maximum number of bytes to be read from the current stream.
cancellationToken
CancellationTokenThe token to monitor for cancellation requests. The default value is System.Threading.CancellationToken.None.
Returns
- Task<int>
The total number of bytes read into the buffer. This can be less than the number of bytes requested if that many bytes are not currently available, or zero (0) if the end of the stream has been reached.
Seek(long, SeekOrigin)
Sets the position within the current stream. DecryptStream does not support seeking, attempting to call Seek will throw NotSupportedException.
public override long Seek(long offset, SeekOrigin origin)
Parameters
offset
longA byte offset relative to the origin parameter.
origin
SeekOriginA value of type System.IO.SeekOrigin indicating the reference point used to obtain the new position.
Returns
- long
The new position within the current stream.