-
Notifications
You must be signed in to change notification settings - Fork 1
AESHMAC512 DataTable Extension
To start using the DataTable extension functions add the NuGet package or reference the DLL file in your solution.
then add the following namespace.
using DotNetAES.Extensions;
The following DataTable will be used in all examples below.
DataTable dt = new DataTable()
{
Columns =
{
"column_one","column_two", "column_three", "column_four", "column_five", "column_iv",
},
Rows =
{
{ "one", "two", "three", "four", "five" },
{ "one2", "two2", "three2", "four2", "five2" },
{ "3one", "t3wo", "three3", "four3", "five3" },
{ 2, 3, 4, 5, 6 },
{ DateTime.Now, 2, 3 },
}
};
To start using the DataTable extension functions add the following namespace.
using DotNetAES.Extensions;
This function encrypts all the columns in a DataTable.
Syntax
DataTable AESHMAC512Encrypt(this DataTable data, AESHMAC512 encryptionEngine, object cryptKey, object authKey)
Example Usage
AESHMAC512 AESHMAC512 = new AESHMAC512 ();
// Generates a encryption key and the authentication key for the example
string cryptKey = AESHMAC512.CreateAESStringKey();
string authKey = AESHMAC512.CreateHMACAuthenticationStringKey();
// Encrypts the DataTable and returns it
dt = dt.AESHMAC512Encrypt(AESHMAC512, cryptKey, authKey);
This function encrypts all the columns in a DataTable except all column names in the ignore list.
Syntax
DataTable AESHMAC512EncryptIgnore(this DataTable data, AESHMAC512 encryptionEngine, object cryptKey, object authKey, params string[] ignoreColumns)
Example Usage
AESHMAC512 AESHMAC512 = new AESHMAC512 ();
// Generates a encryption key and the authentication key for the example
string cryptKey = AESHMAC512.CreateAESStringKey();
string authKey = AESHMAC512.CreateHMACAuthenticationStringKey();
//Encrypts the DataTable and returns it
dt = dt.AESHMAC512EncryptIgnore(AESHMAC512, cryptKey, authKey, "column_two");
This function encrypts only the specified columns in a DataTable.
Syntax
DataTable AESHMAC512EncryptOnly(this DataTable data, AESHMAC512 encryptionEngine, object cryptKey, object authKey, params string[] onlyColumns)
Example Usage
AESHMAC512 AESHMAC512 = new AESHMAC512 ();
// Generates a encryption key and the authentication key for the example
string cryptKey = AESHMAC512.CreateAESStringKey();
string authKey = AESHMAC512.CreateHMACAuthenticationStringKey();
//Encrypts the DataTable and returns it
dt = dt.AESHMAC512EncryptOnly(AESHMAC512, cryptKey, authKey, "column_two");
This function decrypts all the columns in a DataTable.
Syntax
DataTable AESHMAC512Decrypt(this DataTable data, AESHMAC512 encryptionEngine, object cryptKey, object authKey)
Example Usage
AESHMAC512 AESHMAC512 = new AESHMAC512 ();
// Generates a encryption key and the authentication key for the example
string cryptKey = AESHMAC512.CreateAESStringKey();
string authKey = AESHMAC512.CreateHMACAuthenticationStringKey();
//Decrypts the DataTable and returns it
dt = dt.AESHMAC512Decrypt(AESHMAC512, cryptKey, authKey);
This function decrypts all the columns in a DataTable except all column names in the ignore list.
Syntax
DataTable AESHMAC512DecryptIgnore(this DataTable data, AESHMAC512 encryptionEngine, object cryptKey, object authKey, params string[] ignoreColumns)
Example Usage
AESHMAC512 AESHMAC512 = new AESHMAC512 ();
// Generates a encryption key and the authentication key for the example
string cryptKey = AESHMAC512.CreateAESStringKey();
string authKey = AESHMAC512.CreateHMACAuthenticationStringKey();
//Decrypts the DataTable and returns it
dt = dt.AESDecryptIgnore(AESHMAC512, cryptKey, authKey, "column_two");
This function decrypts only the specified columns in a DataTable.
Syntax
DataTable AESHMAC512DecryptOnly(this DataTable data, AESHMAC512 encryptionEngine, object cryptKey, object authKey, params string[] onlyColumns)
Example Usage
AESHMAC512 AESHMAC512 = new AESHMAC512 ();
// Generates a encryption key and the authentication key for the example
string cryptKey = AESHMAC512.CreateAESStringKey();
string authKey = AESHMAC512.CreateHMACAuthenticationStringKey();
//Decrypts the DataTable and returns it
dt = dt.AESHMAC512DecryptOnly(AESHMAC512, cryptKey, authKey, "column_two");