UtilEncryptionAesEncrypt Method

Encrypts a string using AES algorithm.

Definition

Namespace: DevCase.Core.Security.Cryptography.Encryption
Assembly: DevCase.net48 (in DevCase.net48.dll) Version: 6.0.0.0 (6.0)
XMLNS for XAML: Not mapped to an xmlns.
public static string AesEncrypt(
	string str,
	string key,
	int size,
	byte[] salt = null,
	CipherMode mode = CipherMode.ECB,
	Encoding enc = null
)

Parameters

str  String
The string to encrypt.
key  String
The encryption key.
size  Int32
The key size.

128, 192 or 256 bits.

salt  Byte  (Optional)
The key salt.
mode  CipherMode  (Optional)
The AES encryption mode.
enc  Encoding  (Optional)
The text Encoding.

Return Value

String
The encrypted string.

Example

This is a code example.
C#
No code example is currently available or this language may not be supported.

Exceptions

ArgumentException A value of 128, 192 or 256 is required for AES algorithm.;size or Salt should contain at least 8 bytes.;salt

See Also