Click or drag to resize

CryptographyEncrypt(String, String, SymmetricAlgorithm) Method

Encrypts a string using a specified symmetrical encryption algorithm.

Namespace: InnerDrive.Core
Assembly: InnerDrive.Core (in InnerDrive.Core.dll) Version: 5.0.8475.0
Syntax
C#
public static Task<string> Encrypt(
	string plainText,
	string key,
	SymmetricAlgorithm provider
)

Parameters

plainText  String
The string to encrypt.
key  String
The key to encrypt the plaintext.
provider  SymmetricAlgorithm
Any symmetric cryptography provider derived from SymmetricAlgorithm to perform the encryption.

Return Value

TaskString
A Base64-encoded String containing the ciphertext.
Exceptions
ExceptionCondition
ArgumentNullExceptionThrown if plainText, or key, or provider is null.
ArgumentExceptionThrown if plainText or key is Empty.
Remarks

The default encryption algorithm is DES. Any other class derived from SymmetricAlgorithm can be used instead.

Adapted from work by Frank Fong and William Rawls of the Code Project.

See Also