Skip to content

NotPppp1116/rust-file

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

rust-file

rust-file is a small Rust command-line archive tool. It packs the files in a directory into a custom archive format, compresses the archive with zstd, and encrypts it with XChaCha20-Poly1305 using a key derived from your password with Argon2.

It also includes simple TCP send/receive commands and UDP discovery helpers for finding a receiver on the local network.

Status

This is an experimental project. Be careful with real data.

Important: encrypt --dir <directory_path> deletes the source directory after it writes the encrypted archive.

Build

cargo build

For an optimized binary:

cargo build --release

Run tests and lints:

cargo test
cargo clippy --all-targets --all-features

Usage

Show help by running the binary without a valid command:

cargo run --

Encrypt a directory

cargo run -- encrypt --dir <directory_path>

The program asks for:

  • a password
  • a zstd compression level from -7 to 22

It writes an archive named like:

mole_<uuid>.bin

After writing the archive, the source directory is removed.

Decrypt an archive

cargo run -- decrypt <archive_path> [output_directory]

If output_directory is omitted, files are restored into the current directory.

Send an encrypted archive over TCP

The sender can send the encrypted archive after creating it:

cargo run -- encrypt --dir <directory_path> --send <host:port>

Example:

cargo run -- encrypt --dir ./secret --send 192.168.1.20:9000

Receive an archive over TCP

On the receiving machine:

cargo run -- receive <host:port>

Example:

cargo run -- receive 0.0.0.0:9000

The received bytes are written to a generated mole_*.bin archive file.

Receiver discovery

Discovery uses UDP port 9001.

On the receiver, advertise a file name and the TCP address where it can receive:

cargo run -- serve-discovery <file_name> <host:port>

Example:

cargo run -- serve-discovery backup.bin 192.168.1.20:9000

On another machine, search for that receiver:

cargo run -- find-receiver <file_name>

Example:

cargo run -- find-receiver backup.bin

If a matching receiver answers within 3 seconds, the command prints the receiver address.

Archive Format

The encrypted file contains:

  1. 16-byte random salt
  2. 24-byte random nonce
  3. encrypted zstd-compressed archive bytes

Inside the compressed archive, metadata is written in little-endian fields, followed by file names, relative paths, and file contents.

License

Apache License 2.0. See LICENSE.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages