Skip to content

Encrypt Method ​

Definition ​

  • Namespace: JASE.Crypto
  • Assembly: JASE.Crypto.dll

Overloads ​

NameDescription
byte[] Encrypt(byte[] input, AesGcmOptions options)Encrypts a byte array using AES-GCM with the provided associated AesGcmOptions
string Encrypt(string input, AesGcmOptions options)Encrypts a string using AES-GCM with the provided associated AesGcmOptions
byte[] Encrypt(byte[] input, byte[] key, byte[] associatedMetaData = null, Encoding encoding = null, AesEnvelopeFormat? format = null)Encrypts a byte array using AES-GCM with the given key and optional associated metadata.
string Encrypt(string input, byte[] key, byte[] associatedMetaData = null, Encoding encoding = null, AesEnvelopeFormat? format = null)Encrypts a string using AES-GCM with the given key and optional associated metadata.
byte[] Encrypt(byte[] input, string passPhrase, string salt, byte[] associatedMetaData = null, Encoding encoding = null, int iterations = null, AesEnvelopeFormat? format = null)Encrypts a string using AES-GCM with a passphrase and salt.
byte[] Encrypt(byte[] input, string passPhrase, string salt, string associatedMetaData, Encoding encoding = null, int iterations = null, AesEnvelopeFormat? format = null)Encrypts a string using AES-GCM with a passphrase and salt.
string Encrypt(string input, string passPhrase, string salt, byte[] associatedMetaData = null, Encoding encoding = null, int iterations = null, AesEnvelopeFormat? format = null)Encrypts a string using AES-GCM with a passphrase and salt.
string Encrypt(string input, string passPhrase, string salt, string associatedMetaData, Encoding encoding = null, int iterations = null, AesEnvelopeFormat? format = null)Encrypts a string using AES-GCM with a passphrase and salt.

byte[] Encrypt(byte[] input, AesGcmOptions options) ​

csharp
byte[] Encrypt(byte[] input, AesGcmOptions options)

Encrypts a byte array using AES-GCM with the provided associated AesGcmOptions

byte[] Encrypt(byte[] input, byte[] key, byte[] associatedMetaData = null, Encoding encoding = null, AesEnvelopeFormat? format = null) ​

csharp
byte[] Encrypt(byte[] input, byte[] key, byte[] associatedMetaData = null, Encoding encoding = null, AesEnvelopeFormat? format = null)

Encrypts a byte array using AES-GCM with the given key and optional associated metadata.

Parameters ​

NameDescription
associatedMetaDataOptional associated metadata for the encryption.
inputThe input data to be encrypted as a byte array.
keyThe encryption key.

Returns ​

The encrypted data as a byte array.

byte[] Encrypt(byte[] input, string passPhrase, string salt, byte[] associatedMetaData = null, Encoding encoding = null, int iterations = null, AesEnvelopeFormat? format = null) ​

csharp
byte[] Encrypt(byte[] input, string passPhrase, string salt, byte[] associatedMetaData = null, Encoding encoding = null, int iterations = null, AesEnvelopeFormat? format = null)

Encrypts a string using AES-GCM with a passphrase and salt.

Parameters ​

NameDescription
associatedMetaDataOptional associated metadata for the encryption.
encodingOptional encoding for string conversions (default is UTF-8).
inputThe input data to be encrypted as a byte[].
iterationsThe number of iterations used in the PBKDF2 algorithm. Higher values increase brute-force cost at the expense of CPU time. The default is 210,000 (DEFAULT_ITERATIONS), matching library-wide PBKDF2 defaults.
passPhraseThe passphrase used to derive the encryption key.
saltThe salt used to derive the encryption key.

Returns ​

The encrypted data as a Base64 encoded string.

byte[] Encrypt(byte[] input, string passPhrase, string salt, string associatedMetaData, Encoding encoding = null, int iterations = null, AesEnvelopeFormat? format = null) ​

csharp
byte[] Encrypt(byte[] input, string passPhrase, string salt, string associatedMetaData, Encoding encoding = null, int iterations = null, AesEnvelopeFormat? format = null)

Encrypts a string using AES-GCM with a passphrase and salt.

Parameters ​

NameDescription
associatedMetaDataOptional associated metadata for the encryption.
encodingOptional encoding for string conversions (default is UTF-8).
inputThe input data to be encrypted as a byte[].
iterationsThe number of iterations used in the PBKDF2 algorithm. Higher values increase brute-force cost at the expense of CPU time. The default is 210,000 (DEFAULT_ITERATIONS), matching library-wide PBKDF2 defaults.
passPhraseThe passphrase used to derive the encryption key.
saltThe salt used to derive the encryption key.

Returns ​

The encrypted data as a Base64 encoded string.

string Encrypt(string input, AesGcmOptions options) ​

csharp
string Encrypt(string input, AesGcmOptions options)

Encrypts a string using AES-GCM with the provided associated AesGcmOptions

string Encrypt(string input, byte[] key, byte[] associatedMetaData = null, Encoding encoding = null, AesEnvelopeFormat? format = null) ​

csharp
string Encrypt(string input, byte[] key, byte[] associatedMetaData = null, Encoding encoding = null, AesEnvelopeFormat? format = null)

Encrypts a string using AES-GCM with the given key and optional associated metadata.

Parameters ​

NameDescription
associatedMetaDataOptional associated metadata for the encryption.
encodingOptional encoding for string conversions (default is UTF-8).
inputThe input data to be encrypted as a string.
keyThe encryption key.

Returns ​

The encrypted data as a Base64 encoded string.

string Encrypt(string input, string passPhrase, string salt, byte[] associatedMetaData = null, Encoding encoding = null, int iterations = null, AesEnvelopeFormat? format = null) ​

csharp
string Encrypt(string input, string passPhrase, string salt, byte[] associatedMetaData = null, Encoding encoding = null, int iterations = null, AesEnvelopeFormat? format = null)

Encrypts a string using AES-GCM with a passphrase and salt.

Parameters ​

NameDescription
associatedMetaDataOptional associated metadata for the encryption.
encodingOptional encoding for string conversions (default is UTF-8).
inputThe input data to be encrypted as a string.
iterationsThe number of iterations used in the PBKDF2 algorithm. Higher values increase brute-force cost at the expense of CPU time. The default is 210,000 (DEFAULT_ITERATIONS), matching library-wide PBKDF2 defaults.
passPhraseThe passphrase used to derive the encryption key.
saltThe salt used to derive the encryption key.

Returns ​

The encrypted data as a Base64 encoded string.

string Encrypt(string input, string passPhrase, string salt, string associatedMetaData, Encoding encoding = null, int iterations = null, AesEnvelopeFormat? format = null) ​

csharp
string Encrypt(string input, string passPhrase, string salt, string associatedMetaData, Encoding encoding = null, int iterations = null, AesEnvelopeFormat? format = null)

Encrypts a string using AES-GCM with a passphrase and salt.

Parameters ​

NameDescription
associatedMetaDataOptional associated metadata for the encryption.
encodingOptional encoding for string conversions (default is UTF-8).
inputThe input data to be encrypted as a string.
iterationsThe number of iterations used in the PBKDF2 algorithm. Higher values increase brute-force cost at the expense of CPU time. The default is 210,000 (DEFAULT_ITERATIONS), matching library-wide PBKDF2 defaults.
passPhraseThe passphrase used to derive the encryption key.
saltThe salt used to derive the encryption key.

Returns ​

The encrypted data as a Base64 encoded string.