Git Product home page Git Product logo

file-checksum's Introduction

File Checksum

Tests Status

Generate checksums for files.

This program will generate checksums for either a single file, or all the files in a directory.

Installation

Install with cargo:

cargo install file-checksum

Install on Debian/Ubuntu:

curl -LO https://github.com/sanders41/python-project-generator/releases/download/v1.0.16/python-project-generator_1.0.16_amd64.deb
sudo dpkg -i python-project-generator_1.0.16_amd64.deb

file-checksum can also be installed with binaries provided with each release here.

Usage

Generate

  • Arguments:

    • <CHECKSUM_PATH> Path to the directory or file for which to generate checksums
  • Options:

    • -o, --output-file <OUTPUT_FILE> Path to the file to same the checksums. Must be a .txt file. If no path is provided the output will be printed to the screen and not saved
    • -c, --checksum-type <CHECKSUM_TYPE> The type of checksum to generate. [default: sha256] [possible values: md5, sha1, sha256]
    • --overwrite Overwrite the output file rather than appending to it
    • -v, --verbose Provides more output while running
    • -h, --help Print help

Example

If we have the files my_file_1.xml and my_file_2.xml in the home/my_files directory, checksums can be generated for the files by running:

checksum /home/my_files -o /home/checksums.txt

The will create a file called checksums.txt in the /home directory containing the following information (hashes made up for example purposes)

sha256 checksum: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 - my_file_1.xml
sha256 checksum: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 - my_file_2.xml

Subsequent runs pointing to the same output file will append the results to the file so checksums from different directores can be save to the same file. Passing the --overwrite flag will clear the contents of the file before writing instead of appending to the file.

Contributing

Contributions to this project are welcome. If you are interesting in contributing please see our contributing guide

file-checksum's People

Contributors

dependabot[bot] avatar pre-commit-ci[bot] avatar sanders41 avatar

Stargazers

 avatar

Watchers

 avatar

file-checksum's Issues

Add an overwrite flag to generate

Add an overwrite boolean flag to the generate command. When this flag is set the output file should be overwritten rather than appended to. The default value should be False. If no output file is specified the overwrite flag will be ignored.

This flag can only have the default long flag of overwrite with no short option.

The value of the flag will be passed to _process_checksum and used here updating it to:

        if overwrite:
            with open(output_file, "w") as f:
                f.write(f"{checksum_output}\n")
        else:
            with open(output_file, "a") as f:
                f.write(f"{checksum_output}\n")

Additionally tests should be added to make sure both overwriting and appending work as expected.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.