Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

s3-etag

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

s3-etag - npm Package Compare versions

Comparing version 0.0.6 to 0.0.7

4

package.json
{
"name": "s3-etag",
"version": "0.0.6",
"version": "0.0.7",
"private": false,
"description": "Generate an S3 ETAG for multipart uploads in Node.js",
"description": "Generate an accurate S3 ETAG for multipart uploads in Node.js",
"exports": "./index.js",

@@ -7,0 +7,0 @@ "type": "module",

@@ -21,9 +21,24 @@ # S3 ETAG

// Simple MD5 hash of contents for non-multipart files
const etag = generateETag(absoluteFilePath);
expect(etag).toBe('ba0b9fe20dc67b0e4c478ab3c03dc5ce');
// MD5 hash of combined contents & part number (see below) for multipart files
const partSizeInBytes = 10 * 1024 * 1024; // 10mb
const etag = generateETag(absoluteFilePath, partSizeInBytes);
```
## How It Works
This is a Node.js implementation of [this algorithm](https://stackoverflow.com/a/19896823/492325).
At a high level:
- If no `partSizeInBytes` is specified, return MD5 hash of file contents
- If `partSizeInBytes` is specified:
- Generate parts by comparing `partSizeInBytes` to the file size
- Read each part from the file, MD5 hash the part, and append it to a global combined hash
- Once all parts are processed, generate a new MD5 from the global combined hash, and suffix with the amount of parts
## License
See [LICENSE.md](./LICENSE.md).
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc