Releases: mm9942/crypt_guard
V1.3.10 - Fix for rust beta: 1.85.0-beta.5
New Version: V1.3.10
Fix for rust beta: 1.85.0-beta.5
New Features since: V1.3.9
New Features:
Macros:
ArchiveUtil!(path, delete_flag, Variant);$path: The path to the directory/file to archive or the archive file to extract. Accepts a&stror aPathBuf.$delete_flag: A boolean indicating whether to delete the original directory/file or the archive file after the operation.Variant: Specifies the operation type. UseArchiveto compress andExtractto decompress.
Variants:
Archive: Compresses the specified directory or file.Extract: Decompresses the specified archive file.
extract!(archive_path, delete_archive);$archive_path: The path to the.tar.xzarchive you intend to extract. It can be a&stror aPathBuf.$delete_archive: A boolean flag indicating whether to delete the archive file after extraction (trueto delete,falseto retain).
archive!(source_path, delete_dir);$source_path: The path to the directory or file you wish to archive. It can be provided as a&stror aPathBuf.$delete_dir: A boolean flag indicating whether to delete the original directory or file after archiving (trueto delete,falseto retain).
Zip Manager:
Zipping Files and Directories Using the ZipManager
CryptGuard introduces the ZipManager, a utility for archiving multiple files and directories into a single ZIP archive. This tool simplifies the process of creating ZIP files by providing an easy-to-use API. Macros for zipping will be added later.
Example 1: Zipping Both Files and Directories
In this example, we'll demonstrate how to zip multiple files and directories into one ZIP archive.
use crypt_guard::zip_manager::*;
use std::path::PathBuf;
use std::fs;
fn main() -> Result<(), Box<dyn std::error::Error>> {
// Setting up sample files and directories
// Create a sample directory
fs::create_dir_all("sample_dir")?;
fs::create_dir_all("sample_dir/nested_dir")?;
// Create sample files
fs::write("file1.txt", "This is the content of file1.")?;
fs::write("file2.txt", "This is the content of file2.")?;
fs::write("sample_dir/file3.txt", "This is the content of file3 in sample_dir.")?;
fs::write("sample_dir/nested_dir/file4.txt", "This is the content of file4 in nested_dir.")?;
// Specify the output ZIP file path
let output_zip = "archive_with_dirs.zip";
// Create a new ZipManager instance
let mut manager = ZipManager::new(output_zip);
// Add individual files to the zip
manager.add_file("file1.txt");
manager.add_file("file2.txt");
// Add directories to the zip
manager.add_directory("sample_dir");
// Create the ZIP archive with Deflated compression
manager.create_zip(Compression::Deflated)?;
println!("ZIP archive created at {}", output_zip);
// Cleanup sample files and directories
fs::remove_file("file1.txt")?;
fs::remove_file("file2.txt")?;
fs::remove_dir_all("sample_dir")?;
Ok(())
}Example 2: Zipping Multiple Files Only
Here's how to zip multiple individual files into a single ZIP archive.
use crypt_guard::zip_manager::*;
use std::fs;
fn main() -> Result<(), Box<dyn std::error::Error>> {
// Setting up sample files
fs::write("file1.txt", "Content of file1")?;
fs::write("file2.txt", "Content of file2")?;
fs::write("file3.txt", "Content of file3")?;
// Specify the output ZIP file path
let output_zip = "archive_with_files.zip";
// Create a new ZipManager instance
let mut manager = ZipManager::new(output_zip);
// Add files to zip
manager.add_file("file1.txt");
manager.add_file("file2.txt");
manager.add_file("file3.txt");
// Create the ZIP archive with Deflated compression
manager.create_zip(Compression::Deflated)?;
println!("ZIP archive created at {}", output_zip);
// Cleanup sample files
fs::remove_file("file1.txt")?;
fs::remove_file("file2.txt")?;
fs::remove_file("file3.txt")?;
Ok(())
}Compression Methods
The ZipManager allows you to choose from different compression methods depending on your needs. The available options are:
Compression::stored(): No compression is applied. Use this option for faster archiving when compression is unnecessary.Compression::deflated(): Standard ZIP compression. Offers a good balance between compression ratio and speed.Compression::zip2(): Uses Bzip2 compression. Provides higher compression ratios but may be slower.Compression::zstd(): Uses Zstandard compression. Offers high compression ratios and speed. Note that to use Zstandard compression, you need to enable thezstdfeature in thezipcrate.
Full Changelog: V1.3.0...V1.3.9
V1.3.9
New Version: V1.3.9
New Features:
Macros:
ArchiveUtil!(path, delete_flag, Variant);$path: The path to the directory/file to archive or the archive file to extract. Accepts a&stror aPathBuf.$delete_flag: A boolean indicating whether to delete the original directory/file or the archive file after the operation.Variant: Specifies the operation type. UseArchiveto compress andExtractto decompress.
Variants:
Archive: Compresses the specified directory or file.Extract: Decompresses the specified archive file.
extract!(archive_path, delete_archive);$archive_path: The path to the.tar.xzarchive you intend to extract. It can be a&stror aPathBuf.$delete_archive: A boolean flag indicating whether to delete the archive file after extraction (trueto delete,falseto retain).
archive!(source_path, delete_dir);$source_path: The path to the directory or file you wish to archive. It can be provided as a&stror aPathBuf.$delete_dir: A boolean flag indicating whether to delete the original directory or file after archiving (trueto delete,falseto retain).
Zip Manager:
Zipping Files and Directories Using the ZipManager
CryptGuard introduces the ZipManager, a utility for archiving multiple files and directories into a single ZIP archive. This tool simplifies the process of creating ZIP files by providing an easy-to-use API. Macros for zipping will be added later.
Example 1: Zipping Both Files and Directories
In this example, we'll demonstrate how to zip multiple files and directories into one ZIP archive.
use crypt_guard::zip_manager::*;
use std::path::PathBuf;
use std::fs;
fn main() -> Result<(), Box<dyn std::error::Error>> {
// Setting up sample files and directories
// Create a sample directory
fs::create_dir_all("sample_dir")?;
fs::create_dir_all("sample_dir/nested_dir")?;
// Create sample files
fs::write("file1.txt", "This is the content of file1.")?;
fs::write("file2.txt", "This is the content of file2.")?;
fs::write("sample_dir/file3.txt", "This is the content of file3 in sample_dir.")?;
fs::write("sample_dir/nested_dir/file4.txt", "This is the content of file4 in nested_dir.")?;
// Specify the output ZIP file path
let output_zip = "archive_with_dirs.zip";
// Create a new ZipManager instance
let mut manager = ZipManager::new(output_zip);
// Add individual files to the zip
manager.add_file("file1.txt");
manager.add_file("file2.txt");
// Add directories to the zip
manager.add_directory("sample_dir");
// Create the ZIP archive with Deflated compression
manager.create_zip(Compression::Deflated)?;
println!("ZIP archive created at {}", output_zip);
// Cleanup sample files and directories
fs::remove_file("file1.txt")?;
fs::remove_file("file2.txt")?;
fs::remove_dir_all("sample_dir")?;
Ok(())
}Example 2: Zipping Multiple Files Only
Here's how to zip multiple individual files into a single ZIP archive.
use crypt_guard::zip_manager::*;
use std::fs;
fn main() -> Result<(), Box<dyn std::error::Error>> {
// Setting up sample files
fs::write("file1.txt", "Content of file1")?;
fs::write("file2.txt", "Content of file2")?;
fs::write("file3.txt", "Content of file3")?;
// Specify the output ZIP file path
let output_zip = "archive_with_files.zip";
// Create a new ZipManager instance
let mut manager = ZipManager::new(output_zip);
// Add files to zip
manager.add_file("file1.txt");
manager.add_file("file2.txt");
manager.add_file("file3.txt");
// Create the ZIP archive with Deflated compression
manager.create_zip(Compression::Deflated)?;
println!("ZIP archive created at {}", output_zip);
// Cleanup sample files
fs::remove_file("file1.txt")?;
fs::remove_file("file2.txt")?;
fs::remove_file("file3.txt")?;
Ok(())
}Compression Methods
The ZipManager allows you to choose from different compression methods depending on your needs. The available options are:
Compression::stored(): No compression is applied. Use this option for faster archiving when compression is unnecessary.Compression::deflated(): Standard ZIP compression. Offers a good balance between compression ratio and speed.Compression::zip2(): Uses Bzip2 compression. Provides higher compression ratios but may be slower.Compression::zstd(): Uses Zstandard compression. Offers high compression ratios and speed. Note that to use Zstandard compression, you need to enable thezstdfeature in thezipcrate.
Full Changelog: V1.3.0...V1.3.9
V1.3.0
New Version: V1.3.0
New Features:
Implementation of AEAD: AES_GCM_SIV. Planned implementation of CTR, CBC and XTS for device encryption!
Full Changelog: V1.2.16...V1.3.0
V1.2.16
Full Changelog: V1.2.11...V1.2.16
V1.2.14 - Macros now Integrating a new safety approach
V1.2.13 Release
Full Changelog: V1.2.11...V1.2.13Release
V1.2.11
Full Changelog: V1.2.9...V1.2.11
V1.2.9
V1.2.3
Full Changelog: V1.2.2...V1.2.3
V1.2.2
Full Changelog: V1.2.0...V1.2.2