Skip to content

Create Method ​

Definition ​

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

Overloads ​

NameDescription
AesGcmOptions Create(byte[] key, byte[] associatedData = null, Encoding encoding = null, AesEnvelopeFormat? format = null)Creates an AesGcmOptions instance using a raw 256-bit AES key.
AesGcmOptions Create(string passphrase, string salt, int iterations = null, byte[] associatedData = null, Encoding encoding = null, KeyDerivationAlgorithm? kdfAlgorithm = null, HashProvider? hashProvider = null, AesEnvelopeFormat? format = null)Creates an AesGcmOptions instance by deriving a 256-bit key from a passphrase and salt, using the specified key-derivation settings, and optional binary associated data.
AesGcmOptions Create(string passphrase, string salt, int iterations = null, string associatedData = null, Encoding encoding = null, KeyDerivationAlgorithm? kdfAlgorithm = null, HashProvider? hashProvider = null, AesEnvelopeFormat? format = null)Creates an AesGcmOptions instance by deriving a 256-bit key from a passphrase and salt, using the specified key-derivation settings, and optional string-based associated data.

AesGcmOptions Create(byte[] key, byte[] associatedData = null, Encoding encoding = null, AesEnvelopeFormat? format = null) ​

csharp
AesGcmOptions Create(byte[] key, byte[] associatedData = null, Encoding encoding = null, AesEnvelopeFormat? format = null)

Creates an AesGcmOptions instance using a raw 256-bit AES key.

Parameters ​

NameDescription
associatedDataOptional associated data (AAD) to be authenticated but not encrypted. This value is passed through to AES-GCM as associatedData. For JWE formats (JweCompact or Jwe), this parameter must be and the JWE header bytes are used as AAD instead.
encodingThe text encoding to use when the envelope format requires string serialization (for example, when producing Base64-encoded payloads). If , DefaultEncoding is used.
formatOptional envelope format that controls how the AES-GCM ciphertext, IV and tag are packaged. If , AesGcmDefaultFormat is used. When set to JweCompact or Jwe, any non-null associatedData will cause a CryptographicException.
keyThe symmetric key material. Must be exactly 32 bytes (256-bit) for AES-GCM when using this overload.

Returns ​

A configured AesGcmOptions instance suitable for use with the AES-GCM encryption helpers.

AesGcmOptions Create(string passphrase, string salt, int iterations = null, byte[] associatedData = null, Encoding encoding = null, KeyDerivationAlgorithm? kdfAlgorithm = null, HashProvider? hashProvider = null, AesEnvelopeFormat? format = null) ​

csharp
AesGcmOptions Create(string passphrase, string salt, int iterations = null, byte[] associatedData = null, Encoding encoding = null, KeyDerivationAlgorithm? kdfAlgorithm = null, HashProvider? hashProvider = null, AesEnvelopeFormat? format = null)

Creates an AesGcmOptions instance by deriving a 256-bit key from a passphrase and salt, using the specified key-derivation settings, and optional binary associated data.

Parameters ​

NameDescription
associatedDataOptional associated data (AAD) as raw bytes. This value is authenticated but not encrypted by AES-GCM. For JWE formats (JweCompact or Jwe), this parameter must be and the JWE header bytes are used as AAD instead.
encodingThe text encoding used when interpreting passphrase and salt for key derivation. If , DefaultEncoding is used.
formatOptional envelope format that controls how the AES-GCM ciphertext, IV and tag are packaged. If , AesGcmDefaultFormat is used.
hashProviderOptional hash provider to use with the key-derivation algorithm. If , the default hash for the selected KDF is used.
iterationsThe iteration count for the key derivation function. Higher values increase the cost of brute-force attacks at the expense of CPU time. Defaults to DEFAULT_ITERATIONS.
kdfAlgorithmOptional key-derivation algorithm to use when deriving the AES key. If , the default algorithm configured in Configuration is used.
passphraseThe passphrase from which the AES key will be derived.
saltThe salt used during key derivation. This should be unique per key and stored alongside the ciphertext if you need to reconstruct the key.

Returns ​

A configured AesGcmOptions instance containing a derived 256-bit key and the specified associated data.

AesGcmOptions Create(string passphrase, string salt, int iterations = null, string associatedData = null, Encoding encoding = null, KeyDerivationAlgorithm? kdfAlgorithm = null, HashProvider? hashProvider = null, AesEnvelopeFormat? format = null) ​

csharp
AesGcmOptions Create(string passphrase, string salt, int iterations = null, string associatedData = null, Encoding encoding = null, KeyDerivationAlgorithm? kdfAlgorithm = null, HashProvider? hashProvider = null, AesEnvelopeFormat? format = null)

Creates an AesGcmOptions instance by deriving a 256-bit key from a passphrase and salt, using the specified key-derivation settings, and optional string-based associated data.

Parameters ​

NameDescription
associatedDataOptional associated data (AAD) as a string. If provided, it is converted to bytes using encoding and used as AAD for AES-GCM. For JWE formats (JweCompact or Jwe), this parameter must be and the JWE header bytes are used as AAD instead.
encodingThe text encoding used to convert associatedData and to interpret the passphrase / salt when deriving the key. If , DefaultEncoding is used.
formatOptional envelope format that controls how the AES-GCM ciphertext, IV and tag are packaged. If , AesGcmDefaultFormat is used.
hashProviderOptional hash provider to use with the key-derivation algorithm (for example, SHA-256, SHA-512). If , the default hash provider for the selected KDF is used.
iterationsThe iteration count for the key derivation function. Higher values increase the cost of brute-force attacks at the expense of CPU time. Defaults to Defaults to DEFAULT_ITERATIONS.
kdfAlgorithmOptional key-derivation algorithm. If , the default key derivation algorithm configured in Configuration is used.
passphraseThe passphrase from which the AES key will be derived.
saltThe salt used during key derivation. This should be unique per key and stored alongside the ciphertext if you need to reconstruct the key.

Returns ​

A configured AesGcmOptions instance containing a derived 256-bit key and the resolved associated data.