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

fprint

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fprint

returns hash digest (fingerprint) of a given buffer, file by it's absolute or relative path or stream in node.js

  • 1.0.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
727
increased by716.85%
Maintainers
1
Weekly downloads
 
Created
Source

Node.js file fingerprinting

Returns hash digest (fingerprint) of a given file or stream in node.js Any hash algorithm that node.js crypto supports can be given.

Install

npm i fprint -S

Usage

fprint(input, algorithm, [next])

Returns algorithm hex hash digest for a given input. Supports both promise and callback interfaces - either pass next<err, digest> as a 3d argument or operate on a returned promise.

input - either Buffer, ReadableStream or file path. Supports both relative and absolute paths

Examples:
const fprint = require('fprint');
const fs = require('fs');
const filepath = '/path/to/file';
const stream = fs.createReadStream(filepath);
const fileContents = fs.readFileSync(filepath);

fprint(file, 'sha256').then(shasum => {
  // operate on sha256 digest
});

fprint(stream, 'sha256').then(shasum => {
  // operate on sha256 digest
});

fprint(filepath, 'sha256').then(shasum => {
  // operate on sha256 digest
})

fprint.sync(buffer, algorithm)

const fs = require('fs');
const fprint = require('fprint');
const file = fs.readFileSync('/path/to/file.min.js');
const md5 = fprint.sync(file, 'md5');

Testing

  1. shasum -a 256 ./test/fixtures/files/* | awk '{print $1}' > ./test/fixtures/sums/sha256
  2. md5 -q ./test/fixtures/files/* > ./test/fixtures/sums/md5
  3. npm test

Keywords

FAQs

Package last updated on 07 Dec 2015

Did you know?

Socket

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.

Install

Related posts

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