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

  • 2.0.1
  • latest
  • 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

API

Package includes TypeScript definitions.

fprint

function fprint(source: Buffer | string | ReadStream, algorithm: string): Promise<string>

Returns a Promise that resolves to a string with algorithm hex hash digest for a given input. input - either Buffer, ReadStream or file path. Supports both relative and absolute paths

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

let shasum = await fprint(file, 'sha256');

let sha256 = fprint(stream, 'sha256');

let shasum = await fprint(filepath, 'sha256')

digestSync

function digestSync(buffer: Buffer, algorithm: string): string

Accepts Buffer and creates it's digest

const { digestSync } = require('fprint');

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

digestStream

function digestStream(stream: ReadStream, algorithm: string): Promise<string>

Accepts stream and creates it's digest

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 23 Apr 2020

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