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

arc-hash

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

arc-hash

ES6 convenience library for hashing arrays, objects, strings as md5 or sha256

  • 1.0.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1.5K
increased by3.05%
Maintainers
1
Weekly downloads
 
Created
Source

arc-hash Build Status

Convenience ES6 hashing library. Supports object, array and string hashing for md5 and sha256

Install

$ npm install arc-hash --save

Features

  • supports md5 and sha256
  • supports arrays and objects that reduce to scalar values

Basic Usage

const ArcHash = require('arc-hash');

// This is an example complex object that reduces to scalar value
const exampleObject = {
    'B': 5,
    'D': {
        'Zebra': 'Camel',
        'Antelope': [0,2,
            {
                'Deep':'Mind'
            },
            ['omega','alpha']
        ]
    },
    'A': 'Is a String',
};

console.log(ArcHash.md5(exampleObject));
/*
 Output: 7d388f6ec86c79805a534c910471c7c7
 Any change to the object including changing the order of an array, or changing the case in a key or a value will result in a new hash
*/


API

ArcHash.md5(value:Unknown)

Take an unknown value and return an md5 hash representing it

ArcHash.sha256(value:Unknown)

Take an unknown value and return a sha256 hash representing it

NOTES & WARNINGS

  1. Array order matters for a hash, object order assignment does not.
  2. Keys and values are case sensitive
  3. Circular object references are not handled
  4. String() is eventually applied to all values, so 5 and '5' will not be seen as different values
  5. This is not incredibly performant, and should not be used for dynamic comparison over potentially large data sets

Testing

npm test

FAQs

Package last updated on 08 Nov 2017

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