UtilEncryptionAesEncrypt Method
Encrypts a string using AES algorithm.
Namespace: DevCase.Core.Security.Cryptography.EncryptionAssembly: 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
)
Public Shared Function AesEncrypt (
str As String,
key As String,
size As Integer,
Optional salt As Byte() = Nothing,
Optional mode As CipherMode = CipherMode.ECB,
Optional enc As Encoding = Nothing
) As String
Dim str As String
Dim key As String
Dim size As Integer
Dim salt As Byte()
Dim mode As CipherMode
Dim enc As Encoding
Dim returnValue As String
returnValue = UtilEncryption.AesEncrypt(str,
key, size, salt, mode, enc)
public:
static String^ AesEncrypt(
String^ str,
String^ key,
int size,
array<unsigned char>^ salt = nullptr,
CipherMode mode = CipherMode::ECB,
Encoding^ enc = nullptr
)
static member AesEncrypt :
str : string *
key : string *
size : int *
?salt : byte[] *
?mode : CipherMode *
?enc : Encoding
(* Defaults:
let _salt = defaultArg salt null
let _mode = defaultArg mode CipherMode.ECB
let _enc = defaultArg enc null
*)
-> string
No code example is currently available or this language may not be supported.
- 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.
String
The encrypted string.
This is a code example.
No code example is currently available or this language may not be supported.
Dim encrypted As String = UtilEncryption.AesEncrypt("Hello World!", "my key", 256)
No code example is currently available or this language may not be supported.
No code example is currently available or this language may not be supported.
No code example is currently available or this language may not be supported.
No code example is currently available or this language may not be supported.
ArgumentException
|
A value of 128, 192 or 256 is required for AES algorithm.;size
or
Salt should contain at least 8 bytes.;salt
|