hashguard

Crates.iohashguard
lib.rshashguard
version
sourcesrc
created_at2023-08-01 19:47:09.479551
updated_at2024-12-11 20:36:07.843495
descriptionCommand-Line tool for ensuring the integrity of files using hash sums
homepage
repositoryhttps://github.com/javaLux/hashguard
max_upload_size
id932156
Cargo.toml error:TOML parse error at line 19, column 1 | 19 | autolib = false | ^^^^^^^ unknown field `autolib`, expected one of `name`, `version`, `edition`, `authors`, `description`, `readme`, `license`, `repository`, `homepage`, `documentation`, `build`, `resolver`, `links`, `default-run`, `default_dash_run`, `rust-version`, `rust_dash_version`, `rust_version`, `license-file`, `license_dash_file`, `license_file`, `licenseFile`, `license_capital_file`, `forced-target`, `forced_dash_target`, `autobins`, `autotests`, `autoexamples`, `autobenches`, `publish`, `metadata`, `keywords`, `categories`, `exclude`, `include`
size0
javaLux (javaLux)

documentation

README

hashguard

Build Status dependency status GitHub license crates.io maintenance-status

Command-Line tool for ensuring the integrity of files using hash sums

  ___ ___               .__      ________                       .___
 /   |   \_____    _____|  |__  /  _____/ __ _______ _______  __| _/
/    ~    \__  \  /  ___/  |  \/   \  ___|  |  \__  \\_  __ \/ __ | 
\    Y    // __ \_\___ \|   Y  \    \_\  \  |  // __ \|  | \/ /_/ | 
 \___|_  /(____  /____  >___|  /\______  /____/(____  /__|  \____ | 
       \/      \/     \/     \/        \/           \/           \/ 

Overview

HashGuard is a lean and efficient command-line tool designed to simplify the process of downloading files from the internet and ensuring their integrity using hash sums. With HashGuard, you can confidently download files and verify their authenticity, providing an extra layer of security to your downloads. It is also possible to verify files on the local system.

Hashguard-Demo

Features

  • Download-Command

    • Download a file and have a specific hash sum calculated depending on the selected hash algorithm
    • Or you can directly enter a known hash sum to compare it after the download. This allows you to check whether the file was changed during the download process
    • Notice
      • If you use the download command, please enclose the URL in double quotation marks. Because by enclosing the URL in double quotation marks, you tell the shell to treat the entire string as a single argument, even if it contains spaces or other special characters. This can prevent errors and unexpected behavior in your shell.
  • Local-Command

    • Allows to hash local files, directories or any byte-buffer (futhermore you can also compare with a specific hash sum)
    • Options
      • path
        • Calculate a hash sum from a file/dir
      • buffer
        • Calculate a hash sum from any given byte buffer
        • What means byte buffer?
          • For example, you can calculate a hash sum from any text that is provided as a String
          • As described in the download command, please enclose the text to be hashed in double quotation marks. This prevents unexpected behavior in your shell.
    • Notice
      • You can only use one option per call. So either path or buffer

  • Hash Verification: Verify the authenticity of downloaded or local files by comparing their hash sum with a provided hash value.

  • Support for Various Hash Algorithms: HashGuard supports different hash algorithms, including SHA-1, SHA2-256, and more. The default Hash-Algorithm is SHA2-256.

  • Intuitive Command-Line Interface: The simple and user-friendly CLI lets you easily calculate and compare hash sums.

  • Log-Level

    • You can enable the application debug mode
      • This provides additional functionality such as logging all relevant operations in a log file.
      • Furthermore, the debug mode can be useful to get detailed information about an error (e.g. display a full backtrace)

Supported OS

  • Linux [All common distributions]
  • MacOs [Tested on MacOs Monterey]
  • Windows 10/11

Prerequisites

Installing Rust

To install Rust on your system, just go to the official Rust website, download and install the Rustup toolchain manager.

Notice: Please refer to the installation instructions for your operating system. For certain operating systems, build tools need to be installed before you can use Rust.

Installation

HashGuard is also available on crates.io Rust community's crate registry. So you can easily install it as binary on your local system. Use the follow command:

cargo install hashguard

Using Natively Compiled Binaries

If you don't have Rust installed or prefer not to build the project yourself, you can use the precompiled binaries provided in the Releases section. Download the appropriate binary for your operating system and architecture, and you're good to go!

Build the project

To build this project from scratch follow these steps:

  • Clone this repository
  • Open a terminal
  • Navigate to the root directory of the project
  • Run the following command
cargo build --release
  • The compiled binary will be available at target/release/

How to use

General Syntax

  • hashguard [OPTIONS] <COMMAND>

Command specific syntax

  • hashguard [OPTIONS] download [OPTIONS] <URL> [HASH_SUM]
  • hashguard [OPTIONS] local [OPTIONS] [HASH_SUM]

Usage Examples

Download-Command

  • Download a file and verify it with a hash sum by using the default hash algorithm SHA2-256:

    hashguard download "https://example.com/file.zip" a1b2c3d4e5f6
    
  • Download a file and calculate a hash sum with a specific hash algorithm:

    hashguard download "https://example.com/file.zip" -a sha2-512
    
  • Use a specific output directory for the downloaded file:

    hashguard download "https://example.com/image.jpg" a1b2c3d4e5f6 -o /path/to/output_directory
    
  • Use the --rename option to rename the file to be downloaded:

    hashguard download "https://example.com/image.jpg" a1b2c3d4e5f6 -r "my_fancy_new_file.jpg"
    

Local-Command

  • Verify a local file with a hash sum using SHA-1:

    hashguard local -p /path/to/local_file.txt a1b2c3d4e5f6 -a sha1
    
  • Calculate a hash sum from a given String:

    hashguard local -b "Hello young Padawan"
    
  • Calculate a hash sum from a local directory with the default hash algorithm:

    hashguard local -p /path/to/test_dir
    

Debug-Option

  • Enable the debug log level:
    hashguard -l debug download "https://example.com/file.zip" a1b2c3d4e5f6
    
    hashguard -l debug local -p /path/to/local_file.txt
    
    • In the event of an error, a full backtrace is displayed
    • In addition, all log outputs are saved in a log file in the application's data directory.
    • You can find out the application data directory with the [--version] command
    • Please note that the application data directory is created as a hidden directory. To see it, you must activate the property for displaying hidden files and folders for your operating system, if you have not already done so

Common-Options

  • Get version info:

    hashguard --version
    
  • Get general help:

    hashguard --help
    
  • Get help on a specific command:

    hashguard download --help
    
    hashguard local --help
    

Supported Hash Algorithms

  • MD5
  • SHA-1
  • SHA2-224
  • SHA2-256
  • SHA2-384
  • SHA2-512

Notice

No colored console output under windows?
HashGuard of course also works with colored console output (errors = red, hints = yellow, success = green).
If no colored text is displayed in the CMD or PowerShell, instead the ANSI escape sequences before and after an output,
then enabling ANSI escape sequence support may help. Open a CMD or PowerShell as admin and execute following command:

reg add HKCU\Console /v VirtualTerminalLevel /t REG_DWORD /d 1

This command adds a registry key that enables the conpty feature, which provides ANSI escape sequence support in the Windows console.
Please re-open the terminal and the colored output should work.

Contributions and Bug Reports

Contributions and bug reports are welcome! If you find any issues or have suggestions for improvements, please open an issue or submit a pull request on my GitHub repository.

License

HashGuard is released under the MIT License.

Disclaimer

While HashGuard aims to provide reliable file verification, it is essential to exercise caution when downloading files from the internet or using local files for verification. Always ensure that you trust the source and the provided hash sum before proceeding.

Commit count: 59

cargo fmt