Early Preview
This is currently very much a preview. Please feel free to try things out,
but don't be upset if anything is not yet working. Feedback is welcome over on our
GitHub Dicussions page.
class System.​Security.​Cryptography.​Rijndael
Assembly: System.Security.Cryptography
Inheritance: object → SymmetricAlgorithm → Rijndael
Implemented Interfaces
- IDisposable Implemented by: SymmetricAlgorithm
Represents the base class from which all implementations of the <see cref="T:System.Security.Cryptography.Rijndael" /> symmetric encryption algorithm must inherit.
Fields and Constants
protected
int
BlockSizeValue
Represents the block size, in bits, of the cryptographic operation.
protected
int
FeedbackSizeValue
Represents the feedback size, in bits, of the cryptographic operation.
protected
byte[]
IVValue
Represents the initialization vector ( <see cref="P:System.Security.Cryptography.SymmetricAlgorithm.IV" /> ) for the symmetric algorithm.
protected
int
KeySizeValue
Represents the size, in bits, of the secret key used by the symmetric algorithm.
protected
byte[]
KeyValue
Represents the secret key for the symmetric algorithm.
protected
KeySizes[]
LegalBlockSizesValue
Specifies the block sizes, in bits, that are supported by the symmetric algorithm.
protected
KeySizes[]
LegalKeySizesValue
Specifies the key sizes, in bits, that are supported by the symmetric algorithm.
protected
CipherMode
ModeValue
Represents the cipher mode used in the symmetric algorithm.
protected
PaddingMode
PaddingValue
Represents the padding mode used in the symmetric algorithm.
Properties
public
int
BlockSize
Gets or sets the block size, in bits, of the cryptographic operation.
public
int
FeedbackSize
Gets or sets the feedback size, in bits, of the cryptographic operation for the Cipher Feedback (CFB) and Output Feedback (OFB) cipher modes.
public
byte[]
IV
Gets or sets the initialization vector ( <see cref="P:System.Security.Cryptography.SymmetricAlgorithm.IV" /> ) for the symmetric algorithm.
public
byte[]
Key
Gets or sets the secret key for the symmetric algorithm.
public
int
KeySize
Gets or sets the size, in bits, of the secret key used by the symmetric algorithm.
public
KeySizes[]
LegalBlockSizes
Gets the block sizes, in bits, that are supported by the symmetric algorithm.
public
KeySizes[]
LegalKeySizes
Gets the key sizes, in bits, that are supported by the symmetric algorithm.
public
CipherMode
Mode
Gets or sets the mode for operation of the symmetric algorithm.
public
PaddingMode
Padding
Gets or sets the padding mode used in the symmetric algorithm.
Methods
public static
Rijndael
Create​()
Creates a cryptographic object to perform the <see cref="T:System.Security.Cryptography.Rijndael" /> algorithm.
Returns A cryptographic object.
public static
Rijndael
Create​(string algName)
Creates a cryptographic object to perform the specified implementation of the <see cref="T:System.Security.Cryptography.Rijndael" /> algorithm.
Returns A cryptographic object.
algName
The name of the specific implementation of <see cref="T:System.Security.Cryptography.Rijndael" /> to create.
public
void
Clear​()
Inherited from SymmetricAlgorithm
Releases all resources used by the <see cref="T:System.Security.Cryptography.SymmetricAlgorithm" /> class.
public
ICryptoTransform
CreateDecryptor​()
Inherited from SymmetricAlgorithm
Creates a symmetric decryptor object with the current <see cref="P:System.Security.Cryptography.SymmetricAlgorithm.Key" /> property and initialization vector ( <see cref="P:System.Security.Cryptography.SymmetricAlgorithm.IV" /> ).
Returns A symmetric decryptor object.
public
ICryptoTransform
CreateDecryptor​(byte[] rgbKey,
byte[] rgbIV)
Inherited from SymmetricAlgorithm
When overridden in a derived class, creates a symmetric decryptor object with the specified <see cref="P:System.Security.Cryptography.SymmetricAlgorithm.Key" /> property and initialization vector ( <see cref="P:System.Security.Cryptography.SymmetricAlgorithm.IV" /> ).
Returns A symmetric decryptor object.
rgbKey
The secret key to use for the symmetric algorithm.
rgbIV
The initialization vector to use for the symmetric algorithm.
public
ICryptoTransform
CreateEncryptor​()
Inherited from SymmetricAlgorithm
Creates a symmetric encryptor object with the current <see cref="P:System.Security.Cryptography.SymmetricAlgorithm.Key" /> property and initialization vector ( <see cref="P:System.Security.Cryptography.SymmetricAlgorithm.IV" /> ).
Returns A symmetric encryptor object.
public
ICryptoTransform
CreateEncryptor​(byte[] rgbKey,
byte[] rgbIV)
Inherited from SymmetricAlgorithm
When overridden in a derived class, creates a symmetric encryptor object with the specified <see cref="P:System.Security.Cryptography.SymmetricAlgorithm.Key" /> property and initialization vector ( <see cref="P:System.Security.Cryptography.SymmetricAlgorithm.IV" /> ).
Returns A symmetric encryptor object.
rgbKey
The secret key to use for the symmetric algorithm.
rgbIV
The initialization vector to use for the symmetric algorithm.
public
byte[]
DecryptCbc​(byte[] ciphertext,
byte[] iv,
PaddingMode paddingMode = 2)
Inherited from SymmetricAlgorithm
Decrypts data using CBC mode with the specified padding mode.
Returns The decrypted plaintext data.
ciphertext
The data to decrypt.
iv
The initialization vector.
paddingMode
The padding mode used to produce the ciphertext and remove during decryption.
public
byte[]
DecryptCbc​(ReadOnlySpan<​byte> ciphertext,
ReadOnlySpan<​byte> iv,
PaddingMode paddingMode = 2)
Inherited from SymmetricAlgorithm
Decrypts data using CBC mode with the specified padding mode.
Returns The decrypted plaintext data.
ciphertext
The data to decrypt.
iv
The initialization vector.
paddingMode
The padding mode used to produce the ciphertext and remove during decryption.
public
int
DecryptCbc​(ReadOnlySpan<​byte> ciphertext,
ReadOnlySpan<​byte> iv,
Span<​byte> destination,
PaddingMode paddingMode = 2)
Inherited from SymmetricAlgorithm
Decrypts data into the specified buffer, using CBC mode with the specified padding mode.
Returns The total number of bytes written to <paramref name="destination" />
ciphertext
The data to decrypt.
iv
The initialization vector.
destination
The buffer to receive the plaintext data.
paddingMode
The padding mode used to produce the ciphertext and remove during decryption.
public
byte[]
DecryptCfb​(byte[] ciphertext,
byte[] iv,
PaddingMode paddingMode = 1,
int feedbackSizeInBits = 8)
Inherited from SymmetricAlgorithm
Decrypts data using CFB mode with the specified padding mode and feedback size.
Returns The decrypted plaintext data.
ciphertext
The data to decrypt.
iv
The initialization vector.
paddingMode
The padding mode used to produce the ciphertext and remove during decryption.
feedbackSizeInBits
The feedback size, specified in bits.
public
byte[]
DecryptCfb​(ReadOnlySpan<​byte> ciphertext,
ReadOnlySpan<​byte> iv,
PaddingMode paddingMode = 1,
int feedbackSizeInBits = 8)
Inherited from SymmetricAlgorithm
Decrypts data using CFB mode with the specified padding mode and feedback size.
Returns The decrypted plaintext data.
ciphertext
The data to decrypt.
iv
The initialization vector.
paddingMode
The padding mode used to produce the ciphertext and remove during decryption.
feedbackSizeInBits
The feedback size, specified in bits.
public
int
DecryptCfb​(ReadOnlySpan<​byte> ciphertext,
ReadOnlySpan<​byte> iv,
Span<​byte> destination,
PaddingMode paddingMode = 1,
int feedbackSizeInBits = 8)
Inherited from SymmetricAlgorithm
Decrypts data into the specified buffer, using CFB mode with the specified padding mode and feedback size.
Returns The total number of bytes written to <paramref name="destination" /> .
ciphertext
The data to decrypt.
iv
The initialization vector.
destination
The buffer to receive the plaintext data.
paddingMode
The padding mode used to produce the ciphertext and remove during decryption.
feedbackSizeInBits
The feedback size, specified in bits.
public
byte[]
DecryptEcb​(byte[] ciphertext,
PaddingMode paddingMode)
Inherited from SymmetricAlgorithm
Decrypts data using ECB mode with the specified padding mode.
Returns The decrypted plaintext data.
ciphertext
The data to decrypt.
paddingMode
The padding mode used to produce the ciphertext and remove during decryption.
public
byte[]
DecryptEcb​(ReadOnlySpan<​byte> ciphertext,
PaddingMode paddingMode)
Inherited from SymmetricAlgorithm
Decrypts data using ECB mode with the specified padding mode.
Returns The decrypted plaintext data.
ciphertext
The data to decrypt.
paddingMode
The padding mode used to produce the ciphertext and remove during decryption.
public
int
DecryptEcb​(ReadOnlySpan<​byte> ciphertext,
Span<​byte> destination,
PaddingMode paddingMode)
Inherited from SymmetricAlgorithm
Decrypts data into the specified buffer, using ECB mode with the specified padding mode.
Returns The total number of bytes written to <paramref name="destination" />
ciphertext
The data to decrypt.
destination
The buffer to receive the plaintext data.
paddingMode
The padding mode used to produce the ciphertext and remove during decryption.
public
void
Dispose​()
Inherited from SymmetricAlgorithm
Releases all resources used by the current instance of the <see cref="T:System.Security.Cryptography.SymmetricAlgorithm" /> class.
protected
void
Dispose​(bool disposing)
Inherited from SymmetricAlgorithm
Releases the unmanaged resources used by the <see cref="T:System.Security.Cryptography.SymmetricAlgorithm" /> and optionally releases the managed resources.
disposing
<see langword="true" /> to release both managed and unmanaged resources; <see langword="false" /> to release only unmanaged resources.
public
byte[]
EncryptCbc​(byte[] plaintext,
byte[] iv,
PaddingMode paddingMode = 2)
Inherited from SymmetricAlgorithm
Encrypts data using CBC mode with the specified padding mode.
Returns The encrypted ciphertext data.
plaintext
The data to encrypt.
iv
The initialization vector.
paddingMode
The padding mode used to produce the ciphertext and remove during decryption.
public
byte[]
EncryptCbc​(ReadOnlySpan<​byte> plaintext,
ReadOnlySpan<​byte> iv,
PaddingMode paddingMode = 2)
Inherited from SymmetricAlgorithm
Encrypts data using CBC mode with the specified padding mode.
Returns The encrypted ciphertext data.
plaintext
The data to encrypt.
iv
The initialization vector.
paddingMode
The padding mode used to produce the ciphertext and remove during decryption.
public
int
EncryptCbc​(ReadOnlySpan<​byte> plaintext,
ReadOnlySpan<​byte> iv,
Span<​byte> destination,
PaddingMode paddingMode = 2)
Inherited from SymmetricAlgorithm
Encrypts data into the specified buffer, using CBC mode with the specified padding mode.
Returns The total number of bytes written to <paramref name="destination" /> .
plaintext
The data to encrypt.
iv
The initialization vector.
destination
The buffer to receive the ciphertext data.
paddingMode
The padding mode used to produce the ciphertext and remove during decryption.
public
byte[]
EncryptCfb​(byte[] plaintext,
byte[] iv,
PaddingMode paddingMode = 1,
int feedbackSizeInBits = 8)
Inherited from SymmetricAlgorithm
Encrypts data using CFB mode with the specified padding mode and feedback size.
Returns The encrypted ciphertext data.
plaintext
The data to encrypt.
iv
The initialization vector.
paddingMode
The padding mode used to produce the ciphertext and remove during decryption.
feedbackSizeInBits
The feedback size, specified in bits.
public
byte[]
EncryptCfb​(ReadOnlySpan<​byte> plaintext,
ReadOnlySpan<​byte> iv,
PaddingMode paddingMode = 1,
int feedbackSizeInBits = 8)
Inherited from SymmetricAlgorithm
Encrypts data using CFB mode with the specified padding mode and feedback size.
Returns The encrypted ciphertext data.
plaintext
The data to encrypt.
iv
The initialization vector.
paddingMode
The padding mode used to produce the ciphertext and remove during decryption.
feedbackSizeInBits
The feedback size, specified in bits.
public
int
EncryptCfb​(ReadOnlySpan<​byte> plaintext,
ReadOnlySpan<​byte> iv,
Span<​byte> destination,
PaddingMode paddingMode = 1,
int feedbackSizeInBits = 8)
Inherited from SymmetricAlgorithm
Encrypts data into the specified buffer, using CFB mode with the specified padding mode and feedback size.
Returns The total number of bytes written to <paramref name="destination" /> .
plaintext
The data to encrypt.
iv
The initialization vector.
destination
The buffer to receive the ciphertext data.
paddingMode
The padding mode used to produce the ciphertext and remove during decryption.
feedbackSizeInBits
The feedback size, specified in bits.
public
byte[]
EncryptEcb​(byte[] plaintext,
PaddingMode paddingMode)
Inherited from SymmetricAlgorithm
Encrypts data using ECB mode with the specified padding mode.
Returns The encrypted ciphertext data.
plaintext
The data to encrypt.
paddingMode
The padding mode used to produce the ciphertext and remove during decryption.
public
byte[]
EncryptEcb​(ReadOnlySpan<​byte> plaintext,
PaddingMode paddingMode)
Inherited from SymmetricAlgorithm
Encrypts data using ECB mode with the specified padding mode.
Returns The encrypted ciphertext data.
plaintext
The data to encrypt.
paddingMode
The padding mode used to produce the ciphertext and remove during decryption.
public
int
EncryptEcb​(ReadOnlySpan<​byte> plaintext,
Span<​byte> destination,
PaddingMode paddingMode)
Inherited from SymmetricAlgorithm
Encrypts data into the specified buffer, using ECB mode with the specified padding mode.
Returns The total number of bytes written to <paramref name="destination" /> .
plaintext
The data to encrypt.
destination
The buffer to receive the ciphertext data.
paddingMode
The padding mode used to produce the ciphertext and remove during decryption.
public
void
GenerateIV​()
Inherited from SymmetricAlgorithm
When overridden in a derived class, generates a random initialization vector ( <see cref="P:System.Security.Cryptography.SymmetricAlgorithm.IV" /> ) to use for the algorithm.
public
void
GenerateKey​()
Inherited from SymmetricAlgorithm
When overridden in a derived class, generates a random key ( <see cref="P:System.Security.Cryptography.SymmetricAlgorithm.Key" /> ) to use for the algorithm.
public
int
GetCiphertextLengthCbc​(int plaintextLength,
PaddingMode paddingMode = 2)
Inherited from SymmetricAlgorithm
Gets the length of a ciphertext with a given padding mode and plaintext length in CBC mode.
Returns The length, in bytes, of the ciphertext with padding.
plaintextLength
The plaintext length, in bytes.
paddingMode
The padding mode used to pad the plaintext to the algorithm's block size.
public
int
GetCiphertextLengthCfb​(int plaintextLength,
PaddingMode paddingMode = 1,
int feedbackSizeInBits = 8)
Inherited from SymmetricAlgorithm
Gets the length of a ciphertext with a given padding mode and plaintext length in CFB mode.
Returns The length, in bytes, of the ciphertext with padding.
plaintextLength
The plaintext length, in bytes.
paddingMode
The padding mode used to pad the plaintext to the feedback size.
feedbackSizeInBits
The feedback size, in bits.
public
int
GetCiphertextLengthEcb​(int plaintextLength,
PaddingMode paddingMode)
Inherited from SymmetricAlgorithm
Gets the length of a ciphertext with a given padding mode and plaintext length in ECB mode.
Returns The length, in bytes, of the ciphertext with padding.
plaintextLength
The plaintext length, in bytes.
paddingMode
The padding mode used to pad the plaintext to the algorithm's block size.
public
void
SetKey​(ReadOnlySpan<​byte> key)
Inherited from SymmetricAlgorithm
Sets the key for this instance.
key
The new key for this instance.
protected
void
SetKeyCore​(ReadOnlySpan<​byte> key)
Inherited from SymmetricAlgorithm
Sets the key for this instance.
key
The new key for this instance.
public
bool
TryDecryptCbc​(ReadOnlySpan<​byte> ciphertext,
ReadOnlySpan<​byte> iv,
Span<​byte> destination,
Int32& bytesWritten,
PaddingMode paddingMode = 2)
Inherited from SymmetricAlgorithm
protected
bool
TryDecryptCbcCore​(ReadOnlySpan<​byte> ciphertext,
ReadOnlySpan<​byte> iv,
Span<​byte> destination,
PaddingMode paddingMode,
Int32& bytesWritten)
Inherited from SymmetricAlgorithm
public
bool
TryDecryptCfb​(ReadOnlySpan<​byte> ciphertext,
ReadOnlySpan<​byte> iv,
Span<​byte> destination,
Int32& bytesWritten,
PaddingMode paddingMode = 1,
int feedbackSizeInBits = 8)
Inherited from SymmetricAlgorithm
protected
bool
TryDecryptCfbCore​(ReadOnlySpan<​byte> ciphertext,
ReadOnlySpan<​byte> iv,
Span<​byte> destination,
PaddingMode paddingMode,
int feedbackSizeInBits,
Int32& bytesWritten)
Inherited from SymmetricAlgorithm
public
bool
TryDecryptEcb​(ReadOnlySpan<​byte> ciphertext,
Span<​byte> destination,
PaddingMode paddingMode,
Int32& bytesWritten)
Inherited from SymmetricAlgorithm
protected
bool
TryDecryptEcbCore​(ReadOnlySpan<​byte> ciphertext,
Span<​byte> destination,
PaddingMode paddingMode,
Int32& bytesWritten)
Inherited from SymmetricAlgorithm
public
bool
TryEncryptCbc​(ReadOnlySpan<​byte> plaintext,
ReadOnlySpan<​byte> iv,
Span<​byte> destination,
Int32& bytesWritten,
PaddingMode paddingMode = 2)
Inherited from SymmetricAlgorithm
protected
bool
TryEncryptCbcCore​(ReadOnlySpan<​byte> plaintext,
ReadOnlySpan<​byte> iv,
Span<​byte> destination,
PaddingMode paddingMode,
Int32& bytesWritten)
Inherited from SymmetricAlgorithm
public
bool
TryEncryptCfb​(ReadOnlySpan<​byte> plaintext,
ReadOnlySpan<​byte> iv,
Span<​byte> destination,
Int32& bytesWritten,
PaddingMode paddingMode = 1,
int feedbackSizeInBits = 8)
Inherited from SymmetricAlgorithm
protected
bool
TryEncryptCfbCore​(ReadOnlySpan<​byte> plaintext,
ReadOnlySpan<​byte> iv,
Span<​byte> destination,
PaddingMode paddingMode,
int feedbackSizeInBits,
Int32& bytesWritten)
Inherited from SymmetricAlgorithm
public
bool
TryEncryptEcb​(ReadOnlySpan<​byte> plaintext,
Span<​byte> destination,
PaddingMode paddingMode,
Int32& bytesWritten)
Inherited from SymmetricAlgorithm
protected
bool
TryEncryptEcbCore​(ReadOnlySpan<​byte> plaintext,
Span<​byte> destination,
PaddingMode paddingMode,
Int32& bytesWritten)
Inherited from SymmetricAlgorithm
public
bool
ValidKeySize​(int bitLength)
Inherited from SymmetricAlgorithm
Determines whether the specified key size is valid for the current algorithm.
Returns <see langword="true" /> if the specified key size is valid for the current algorithm; otherwise, <see langword="false" /> .
bitLength
The length, in bits, to check for a valid key size.
public
bool
Equals​(object obj)
Inherited from object
protected
void
Finalize​()
Inherited from object
public
int
GetHashCode​()
Inherited from object
protected
object
MemberwiseClone​()
Inherited from object
public
string
ToString​()
Inherited from object