1.0.2 • Published 4 months ago

openchain-encryption-nodejs-g49 v1.0.2

Weekly downloads
-
License
ISC
Repository
-
Last release
4 months ago

openchain-encryption-nodejs

openchain-encryption Sub module of openchain-sdk-js.

openchain-encryption-nodejs Installation

npm install openchain-encryption-nodejs --save

openchain-encryption-nodejs Test

npm test

openchain-encryption-nodejs Usage

'use strict';

const encryption = require('openchain-encryption-nodejs');

const KeyPair = encryption.keypair;
const signature = encryption.signature;
const keystore = encryption.keystore;

let kp = new KeyPair();
// Get encPrivateKey, encPublicKey, address
let encPrivateKey = kp.getEncPrivateKey();
let encPublicKey = kp.getEncPublicKey();
let address = kp.getAddress();


console.log('============= bof: ==============');
console.log(`EncPrivateKey is : ${encPrivateKey}`);
console.log(`EncPublicKey is : ${encPublicKey}`);
console.log(`Address hash is : ${address}`);
console.log('============= eof: ==============');

// Get keypair
let keypair = KeyPair.getKeyPair();

// Get encPublicKey
let encPublicKey = KeyPair.getEncPublicKey(encPrivateKey);

// Get address
let address = KeyPair.getAddress(encPublicKey);

// check encPrivateKey
KeyPair.checkEncPrivateKey(encPrivateKey);

// check encPublicKey
KeyPair.checkEncPublicKey(encPublicKey);

// check address
KeyPair.checkAddress(address);

// signature sign and verify
let sign = signature.sign('test', encPrivateKey);
let verify = signature.verify('test', sign, encPublicKey);

// keystore
keystore.encrypt(encPrivateKey, 'test', function(encData) {
  keystore.decrypt(encData, 'test', function(descData) {
    console.log(descData);
  });
});

License

MIT

1.0.2

4 months ago

1.0.1

4 months ago