Skip to main content

encrypt_file

Function encrypt_file 

Source
pub fn encrypt_file(
    password: &str,
    input: &Path,
    output: Option<&Path>,
) -> Result<PathBuf>
Expand description

Encrypts input into a .krf container.

  • password - the encryption password.
  • input - file to encrypt.
  • output - destination path; when None a random-looking hashed name ending in .krf is generated (the original filename never appears on disk unencrypted).

Returns the path of the written container. Output is produced atomically (temp file + rename) with owner-only permissions on Unix.

use std::path::Path;
let out = krypton::encrypt_file("correct horse", Path::new("document.pdf"), None).unwrap();