Walker.Crypto.AESFileEncryptor

A fun little function for encrypting and decrypting a file with AES-256-GCM.

Values

ChunkSize

An integer representing the size of each chunk encrypted (4 MiB, or 4,194,304 bytes).

Methods

EncryptFileAsync(string inputPath, string outputPath, SecureData password, Action? progress = null)

Encrypts a file asynchronously using AES-256-GCM. Reads the input file in 4 MiB chunks, encrypts each chunk with a unique salt and IV, and writes the result as Salt|IV|Ciphertext lines to the output file.

  • Parameters:
    • inputPath: Path of the file to encrypt.
    • outputPath: Path where the encrypted file will be saved.
    • password: Secure password to derive the encryption key via Argon2id.
    • progress: Optional callback for progress tracking, with a value from 0.0 to 1.0.
  • Returns: Task

DecryptFileAsync(string inputPath, string outputPath, SecureData password, Action? progress = null)

Decrypts an encrypted file asynchronously. Reads the encrypted file line by line (each line is a Salt|IV|Ciphertext chunk), decrypts each chunk, and writes the result to the output file.

  • Parameters:
    • inputPath: Path of the encrypted file.
    • outputPath: Path where the decrypted file will be saved.
    • password: Secure password to derive the decryption key via Argon2id.
    • progress: Optional callback for progress tracking.
  • Returns: Task