Security News
JSR Working Group Kicks Off with Ambitious Roadmap and Plans for Open Governance
At its inaugural meeting, the JSR Working Group outlined plans for an open governance model and a roadmap to enhance JavaScript package management.
Get the MD5-sum of a given file, with low memory usage, even on huge files.
The md5-file npm package is a utility for generating MD5 checksums for files. This can be useful for verifying file integrity, detecting changes, and ensuring data consistency.
Generate MD5 checksum for a file
This feature allows you to generate an MD5 checksum for a specified file. The code sample demonstrates how to use the md5-file package to calculate the MD5 hash of a file asynchronously.
const md5File = require('md5-file');
md5File('path/to/file').then(hash => {
console.log(`The MD5 hash of the file is: ${hash}`);
}).catch(err => {
console.error(err);
});
Generate MD5 checksum for a file synchronously
This feature allows you to generate an MD5 checksum for a specified file synchronously. The code sample demonstrates how to use the md5-file package to calculate the MD5 hash of a file in a synchronous manner.
const md5File = require('md5-file');
try {
const hash = md5File.sync('path/to/file');
console.log(`The MD5 hash of the file is: ${hash}`);
} catch (err) {
console.error(err);
}
The built-in Node.js 'crypto' module provides cryptographic functionality that includes a set of wrappers for OpenSSL's hash, HMAC, cipher, decipher, sign, and verify functions. It can be used to generate MD5 checksums, but requires more setup compared to md5-file.
The hasha package is a versatile hashing library that supports multiple algorithms including MD5, SHA-1, SHA-256, and more. It can hash strings, buffers, and files, offering more flexibility compared to md5-file, which is specialized for MD5 checksums of files.
The checksum package is a simple utility for generating checksums for files and strings using various algorithms including MD5, SHA-1, and SHA-256. It provides a more general-purpose solution compared to md5-file, which focuses specifically on MD5 checksums for files.
Get the MD5-sum of a given file, with low memory usage, even on huge files.
npm install --save md5-file
const md5File = require('md5-file')
/* Async usage */
md5File('LICENSE.md').then((hash) => {
console.log(`The MD5 sum of LICENSE.md is: ${hash}`)
})
/* Sync usage */
const hash = md5File.sync('LICENSE.md')
console.log(`The MD5 sum of LICENSE.md is: ${hash}`)
$ md5-file LICENSE.md
ad1faf9381e43c471dc381c17a4ee4b6
md5File(path: string) => Promise<string>
Asynchronously get the MD5-sum of the file at path
.
Returns a Promise
that will be resolved with a string containing the MD5-sum.
md5File.sync(path: string) => string
Synchronously get the MD5-sum of the file at path
.
MIT
FAQs
Get the MD5-sum of a given file, with low memory usage, even on huge files.
The npm package md5-file receives a total of 1,100,869 weekly downloads. As such, md5-file popularity was classified as popular.
We found that md5-file demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
At its inaugural meeting, the JSR Working Group outlined plans for an open governance model and a roadmap to enhance JavaScript package management.
Security News
Research
An advanced npm supply chain attack is leveraging Ethereum smart contracts for decentralized, persistent malware control, evading traditional defenses.
Security News
Research
Attackers are impersonating Sindre Sorhus on npm with a fake 'chalk-node' package containing a malicious backdoor to compromise developers' projects.