@lgslabs/bits-crypto
BITS encrypt/decrypt
Last updated a month ago by lgslab-bot .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install @lgslabs/bits-crypto 
SYNC missed versions from official npm registry.

node-bits-crypto

This is a node module implementation of BITS encrypt/decrypt.

Install

npm install @lgslabs/bits-crypto

File Format

The .enc file has the following format:

  +------------------------+
  +       signature        +
  +      [512 bytes]       +
  +------------------------+
  + RSA encrypted password +
  +      [512 bytes]       +
  +------------------------+
  +   RSA encrypted salt   +
  +      [512 bytes]       +
  +------------------------+
  + RSA encrypted filename +
  +      [512 bytes]       +
  +------------------------+
  +      Symmetric Key     +
  +    encrypted package   +
  +       [file.pack]      +
  +------------------------+

UtilCrypto

const {UtilCrypto} = require('@lgslabs/bits-crypto');

Encrypt data

const {encrypt} = require('@lgslabs/bits-crypto');

const encryptionKey = getPublicEncryptionKey();
const signatureKey = getPrivateSignatureKey();

Promise.resolve()
  .then(() => encrypt({
    input: fs.createReadStream('data.txt'),
    output: fs.createWriteStream('data.txt.enc'),
    encryptionKey: encryptionKey,
    signatureKey: signatureKey,
    filename: 'data.txt',
  })
  .then((signature) => {
    const output = fs.createWriteStream('data.txt.enc', {start: 0, end: 512, flags: 'r+'})
    output.write(signature);
    output.end();
  });

Decrypt data

const {decrypt} = require('@lgslabs/bits-crypto');

const encryptionKey = getPrivateEncryptionKey();
const signatureKey = getPublicSignatureKey();

Promise.resolve()
  .then(() => decrypt({
    input: fs.createReadStream('data.txt.enc'),
    output: fs.createWriteStream('data.txt'),
    encryptionKey: encryptionKey,
    signatureKey: signatureKey,
  });

CLI

This module also provides two scripts to encrypt and decrypt data from the command line. See the help for command details.

npm install -g @lgslabs/bits-crypto
encrypt-data -t data.txt -e foo-key.pub -s mine-key.pem
decrypt-data -t data.enc -e foo-key.pem -s mine-key.pub

Current Tags

  • 2.0.3                                ...           latest (a month ago)

5 Versions

  • 2.0.3                                ...           a month ago
  • 2.0.2                                ...           8 months ago
  • 2.0.1                                ...           a year ago
  • 2.0.0                                ...           a year ago
  • 1.0.1                                ...           a year ago
Downloads
Today 0
This Week 5
This Month 5
Last Day 5
Last Week 0
Last Month 15
Dependencies (3)
Dev Dependencies (3)
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |