Walker.Crypto.AsyncAESEncryption

Provides async-based AES-GCM encryption and decryption with password-derived keys. Includes file encryption helpers, progress tracking, and byte array support.

Types

AESEncryptedText

Holds AES-GCM encrypted data along with the salt and IV (required for Argon2id key derivation).

  • Fields:
    • string Salt: Base64-encoded 16-byte random salt
    • string IV: Base64-encoded 12-byte initialization vector
    • string EncryptedText: Base64-encoded ciphertext + authentication tag
  • Methods:
    • string ToString(): Converts the encrypted data to the format Salt|IV|EncryptedText.
    • static AESEncryptedText FromString(string input): Parses the string in Salt|IV|EncryptedText format. Throws FormatException if invalid.

Methods

EncryptAsync(string plainText, SecureData password, Action? progress = null)

Encrypts plain text using AES-256-GCM asynchronously with a fresh random salt and Argon2id-derived key. Returns an AESEncryptedText containing the salt, IV and encrypted data.

  • Parameters:
    • plainText: Text to encrypt.
    • password: Secure password to derive the encryption key.
    • progress: Optional callback for progress tracking, with a value from 0.0 to 1.0.
  • Returns: Task

DecryptAsync(SimpleAESEncryption.AESEncryptedText encrypted, SecureData password, Action? progress = null)

Decrypts an AESEncryptedText asynchronously and returns the result as a string.

  • Parameters:
    • encrypted: The encrypted data, salt and IV.
    • password: Secure password to derive the decryption key.
    • progress: Optional callback for progress tracking.
  • Returns: Task

DecryptAsync(string encryptedText, string ivBase64, SecureData password, Action? progress = null)

Decrypts a string with a given IV asynchronously using the provided password.

  • Parameters:
    • encryptedText: Base64-encoded encrypted data.
    • ivBase64: Base64-encoded IV.
    • password: Secure password to derive the decryption key.
    • progress: Optional callback for progress tracking.
  • Returns: Task

EncryptBytesAsync(byte[] data, SecureData password, Action? progress = null)

Encrypts a byte array asynchronously. Returns the encrypted data wrapped in an AESEncryptedText.

  • Parameters:
    • data: The byte array to encrypt.
    • password: Secure password to derive the encryption key.
    • progress: Optional callback for progress tracking.
  • Returns: Task

DecryptBytesAsync(SimpleAESEncryptedText encrypted, SecureData password, Action? progress = null)

Decrypts an AESEncryptedText asynchronously and returns the result as a byte array.

  • Parameters:
    • encrypted: The encrypted data, salt and IV.
    • password: Secure password to derive the decryption key.
    • progress: Optional callback for progress tracking.
  • Returns: Task<byte[]>