Skip to content

EncryptWithPassword Method ​

Definition ​

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

Overloads ​

NameDescription
byte[] EncryptWithPassword(byte[] data, string password, byte[] salt, int iterations = null, SymmetricAlgorithms algorithm = null, EncryptionPaddingMode padding = null)Encrypts data with a passphrase using PBKDF2-HMAC-SHA256. The derivation parameters travel with the output so other libraries can reproduce the key. Layout: saltLen(1) ‖ salt ‖ iterations(uint32 BE) ‖ IV ‖ ciphertext.
string EncryptWithPassword(string data, string password, byte[] salt, int iterations = null, SymmetricAlgorithms algorithm = null, EncryptionPaddingMode padding = null)Encrypts a string with a passphrase using PBKDF2-HMAC-SHA256, returning Base64 of the self-describing password container.

byte[] EncryptWithPassword(byte[] data, string password, byte[] salt, int iterations = null, SymmetricAlgorithms algorithm = null, EncryptionPaddingMode padding = null) ​

csharp
byte[] EncryptWithPassword(byte[] data, string password, byte[] salt, int iterations = null, SymmetricAlgorithms algorithm = null, EncryptionPaddingMode padding = null)

Encrypts data with a passphrase using PBKDF2-HMAC-SHA256. The derivation parameters travel with the output so other libraries can reproduce the key. Layout: saltLen(1) ‖ salt ‖ iterations(uint32 BE) ‖ IV ‖ ciphertext.

Parameters ​

NameDescription
algorithmSymmetric algorithm (default AES-256).
dataThe plaintext to encrypt.
iterationsPBKDF2 iteration count (default DEFAULT_ITERATIONS).
paddingBlock padding mode (default PKCS7).
passwordThe passphrase. PBKDF2 uses its UTF-8 bytes.
saltPer-message salt (8–255 bytes; 16+ recommended).

Returns ​

The self-describing password container.

string EncryptWithPassword(string data, string password, byte[] salt, int iterations = null, SymmetricAlgorithms algorithm = null, EncryptionPaddingMode padding = null) ​

csharp
string EncryptWithPassword(string data, string password, byte[] salt, int iterations = null, SymmetricAlgorithms algorithm = null, EncryptionPaddingMode padding = null)

Encrypts a string with a passphrase using PBKDF2-HMAC-SHA256, returning Base64 of the self-describing password container.

Parameters ​

NameDescription
algorithmSymmetric algorithm (default AES-256).
dataThe plaintext string to encrypt.
iterationsPBKDF2 iteration count (default DEFAULT_ITERATIONS).
paddingBlock padding mode (default PKCS7).
passwordThe passphrase. PBKDF2 uses its UTF-8 bytes.
saltPer-message salt (8–255 bytes; 16+ recommended).

Returns ​

Base64-encoded password container.