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

ion-hash-js

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

ion-hash-js

JavaScript implementation of Amazon Ion Hash

  • 0.1.0-SNAPSHOT
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

ion-hash-js

A JavaScript implementation of the Ion Hash Specification.

License

This library is licensed under the Apache 2.0 License.

An implementation of Amazon Ion Hash for JavaScript.

Build Status npm version license [!docs](https://amzn.github.io/ion-hash-js/api)

Getting Started

This library is designed to work with Node 8/ES5/CommonJS.

Node

  1. Add ion-hash-js to your dependencies using npm:

    npm install --save ion-hash-js
    
  2. Use the library to read an Ion value and generate an Ion hash:

    import * as ion from 'ion-js';
    import {cryptoIonHasherProvider, makeHashReader} from 'ion-hash-js';
    
    let ionStr = '[1, 2, 3]';
    let hashReader = makeHashReader(
            ion.makeReader(ionStr),
            cryptoIonHasherProvider('md5'));
    hashReader.next();
    hashReader.next();
    let digest = hashReader.digest();
    
    process.stdout.write('digest:  ');
    digest.forEach(b => {
        process.stdout.write(('0' + ((b as number) & 0xFF).toString(16)).slice(-2) + ' ');
    });
    process.stdout.write('\n');
    

    produces:

    digest: 8f 3b f4 b1 93 5c f4 69 c9 c1 0c 31 52 4b 26 25

  3. Use the library to write Ion data:

    import * as ion from 'ion-js';
    import {cryptoIonHasherProvider, makeHashWriter} from 'ion-hash-js';
    
    let hashWriter = makeHashWriter(
            ion.makeTextWriter(),
            cryptoIonHasherProvider('md5'));
    hashWriter.writeList();
    hashWriter.writeInt(1);
    hashWriter.writeInt(2);
    hashWriter.writeInt(3);
    hashWriter.endContainer();
    let digest = hashWriter.digest();
    
    process.stdout.write('digest:  ');
    digest.forEach(b => {
        process.stdout.write(('0' + ((b as number) & 0xFF)
                .toString(16)).slice(-2) + ' ');
    });
    process.stdout.write('\n');
    

    produces:

    digest: 8f 3b f4 b1 93 5c f4 69 c9 c1 0c 31 52 4b 26 25

Keywords

FAQs

Package last updated on 23 Sep 2019

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