Function hexcrypt::decrypt::decrypt

source ·
pub fn decrypt(
    path: impl AsRef<Path> + Clone,
    out_path: Option<PathBuf>
) -> Result<(), HexCryptError>
Expand description

Decrypts the RGB image from the specified file and converts it back to UTF-8 encoded text.

Arguments

  • path - A reference to a path that points to the image file to be decrypted.
  • out_path - An optional PathBuf representing the output path for the decrypted text. If None, path is used insted (with .txt extension)

Errors

This function can return a HexCryptError enum that represents different error cases, including I/O errors, issues related to image processing, and errors during the conversion of image bytes to text.

Examples

use std::path::PathBuf;
use hexcrypt::decrypt;

let input_path = PathBuf::from("encrypted_image.png");
let output_path = PathBuf::from("decrypted.txt");

match decrypt(input_path, Some(output_path)) {
    Ok(_) => println!("Decryption successful!"),
    Err(e) => eprintln!("Error: {:?}", e),
}