Skip to content

Commit bc8e5db

Browse files
committed
docs: add documentation for library functions
add documentation for encrypt and decrypt file functions. fix typo in readme.
1 parent efc45bb commit bc8e5db

File tree

4 files changed

+31
-3
lines changed

4 files changed

+31
-3
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

encryptify-lib/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
name = "encryptify-lib"
33
description = "A library for encrypting and decrypting files and folders using AES-256 bit encryption."
44
license = "MIT"
5-
version = "1.0.1"
5+
version = "1.0.2"
66
edition = "2021"
77

88
[dependencies]

encryptify-lib/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
3. **AES Encryption**: Supports AES-256 for strong security.
1818

19-
--
19+
---
2020

2121
## Usage
2222

encryptify-lib/src/encryptor_decryptor.rs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,20 @@ use crate::zipper::zip_folder;
99

1010
type Aes256Cbc = Cbc<Aes256, Pkcs7>;
1111

12+
/// Encrypts a file using AES-256 encryption.
13+
///
14+
/// # Arguments
15+
///
16+
/// * `file_path` - Path of the file to encrypt.
17+
/// * `key` - The encryption key. (32 bytes)
18+
///
19+
/// # Panics
20+
///
21+
/// This function will panic if:
22+
/// - The file cannot be read.
23+
/// - The output file cannot be created.
24+
/// - The encrypted data cannot be written to the output file.
25+
///
1226
pub fn encrypt_file(file_path: &str, key: &[u8]) {
1327
let file_content = fs::read(file_path).expect("Failed to read the file");
1428

@@ -26,6 +40,20 @@ pub fn encrypt_file(file_path: &str, key: &[u8]) {
2640
.expect("Failed to write encrypted data to the output file");
2741
}
2842

43+
/// Decrypts an AES-256 encrypted file.
44+
///
45+
/// # Arguments
46+
///
47+
/// * `file_path` - Path of the file to decrypt.
48+
/// * `key` - The encryption key. (32 bytes)
49+
///
50+
/// # Panics
51+
///
52+
/// This function will panic if:
53+
/// - The file cannot be read.
54+
/// - The cipher cannot be created.
55+
/// - The output file cannot be created.
56+
/// - The decrypted data cannot be written to the output file.
2957
pub fn decrypt_file(file_path: &str, key: &[u8]) {
3058
let encrypted_content = fs::read(file_path).expect("Failed to read the encrypted file");
3159

0 commit comments

Comments
 (0)