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

ntc-ncrypto

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ntc-ncrypto

ntc-ncrypto is module node cryptography

  • 0.1.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3
decreased by-82.35%
Maintainers
1
Weekly downloads
 
Created
Source

ntc-ncrypto

ntc-ncrypto is module node cryptography.

Install

npm i ntc-ncrypto

1. An implementation of Shamir's Secret Sharing Algorithm 256-bits in Node

Usage

Use encode/decode Base64Url

const ncrypto = require('ntc-ncrypto');

var s = "nghiatcxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
console.log(s);
console.log(s.length);
// creates a set of shares
var arr = ncrypto.sss.create(3, 6, s, true);
console.log(arr);

// combines shares into secret
var a1 = arr.slice(0, 3);
var s1 = ncrypto.sss.combine(a1, true);
console.log("combines shares 1 length = " + a1.length);
console.log("secret: " + s1);
console.log("secret.length: " + s1.length);

var a2 = arr.slice(3, 6);
var s2 = ncrypto.sss.combine(a2, true);
console.log("combines shares 2 length = " + a2.length);
console.log("secret: " + s2);
console.log("secret.length: " + s2.length);

var a3 = arr.slice(1, 5);
var s3 = ncrypto.sss.combine(a3, true);
console.log("combines shares 3 length = " + a3.length);
console.log("secret: " + s3);
console.log("secret.length: " + s3.length);

Use encode/decode Hex

const ncrypto = require('ntc-ncrypto');

var s = "nghiatcxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
console.log(s);
console.log(s.length);
// creates a set of shares
var arr = ncrypto.sss.create(3, 6, s, false);
console.log(arr);

// combines shares into secret
var a1 = arr.slice(0, 3);
var s1 = ncrypto.sss.combine(a1, false);
console.log("combines shares 1 length = " + a1.length);
console.log("secret: " + s1);
console.log("secret.length: " + s1.length);

var a2 = arr.slice(3, 6);
var s2 = ncrypto.sss.combine(a2, false);
console.log("combines shares 2 length = " + a2.length);
console.log("secret: " + s2);
console.log("secret.length: " + s2.length);

var a3 = arr.slice(1, 5);
var s3 = ncrypto.sss.combine(a3, false);
console.log("combines shares 3 length = " + a3.length);
console.log("secret: " + s3);
console.log("secret.length: " + s3.length);

License

This code is under the Apache License v2.

Keywords

FAQs

Package last updated on 26 May 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