Skip to content

therightstuff/simple-recursive-checksum

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

simple-recursive-checksum

Known Vulnerabilities

Simple checksum determination for files or folders

A simple pure Javascript tool to get a checksum of a single file or of an entire folder.

For a single file this will use the crypto module to get a hash of the file's contents. For a directory, it will recursively get the folder's file hashes (with the files sorted in alphabetical order). This is not standard in any way, but is very useful nonetheless.

Installation

npm install simple-recursive-checksum

Usage

const { checksumFile, checksumDirectory } = require("simple-recursive-checksum");

async function main() {
    const fileHashMd5 = await checksumFile("my_file.txt");
    const fileHashSha256 = await checksumFile("my_file.txt", "sha256");

    const directoryHashMd5 = await checksumDirectory("folder_name");
    const directoryHashSha256 = await checksumDirectory("folder_name", "sha256");

    console.log(fileHashMd5, fileHashSha256, directoryHashMd5, directoryHashSha256);

    return "Done";
}

main()
    .then(console.log)
    .catch(console.error);

About

A simple pure-javascript checksum over files or folders

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published