0.1.5 • Published 7 months ago

@fnet/checksum v0.1.5

Weekly downloads
-
License
MIT
Repository
gitlab
Last release
7 months ago

@fnet/checksum

The @fnet/checksum library is a useful toolset for calculating and verifying checksums of files and directories. Its primary purpose is to ensure data integrity by evaluating the consistency of the content in files or directories. This is useful in situations where you need to verify the data integrity, such as when transferring files between devices or verifying the consistency of backups.

High-Level Functionality

At a basic level, @fnet/checksum leverages hashing algorithms (default is SHA256, but it can be customized) to create a unique hash value representing any given content. This resultant hash value constitutes the checksum of the content.

Here are the highlights of its functionality:

  • The library has a feature that allows it to read and compute the checksum for individual files. This includes checking if the file path specified exists and whether it's actually a file type.

  • Secondly, it has the capability to process directories recursively. It accomplishes this by scanning through all the files within a directory, and the sub-directories within, if any, to generate their checksums.

  • Users can provide input as either a file, a directory, or an object (which could theoretically contain nested objects). It's worth noting that if the input is an object, it should only have string or Buffer values.

  • Across its functionality, one consistent behavior is that it returns an object with two key-value pairs: "integrity" and "inputs". Both properties are of importance. The "integrity" property contains the algorithm used and the hash of the content combined in a string, while the "inputs" property has information regarding the files processed.

  • The code also includes validation steps ensuring appropriate content type and existence of file paths, providing user-friendly error messages when the conditions aren't met.

In summary, the @fnet/checksum library is a versatile tool for working with checksums in multiple scenarios, ensuring reliable and secure data handling. From individual files to complex and nested directories, it provides a robust solution for measuring and verifying data integrity through checksums.

0.1.5

7 months ago

0.1.4

7 months ago

0.1.3

7 months ago