facebook-conceal

Facebook Conceal for node and browser written in ts

Usage no npm install needed!

<script type="module">
  import facebookConceal from 'https://cdn.skypack.dev/facebook-conceal';
</script>

README

Facebook Conceal for node.js

Compatible with Facebook Conceal 2.0

Usage

Conceal

const { Conceal } = require('facebook-conceal');
const conceal = new Conceal('my-password');

// or
const conceal = new Conceal('my-password', myKey, encoding);
// encoding: hex or base64
// myKey: 32 bytes with ${encoding} encoded string

String

const plain = 'hello world @ 2020';
const encrypted = conceal.encryptStr(plain);
const decrypted = conceal.decryptStr(encrypted);

File

const srcFilePath = 'test/xxy007.png';
const encFilePath = `${srcFilePath}.enc`;
const decFilePath = `dec.${srcFilePath}`;

conceal
  .encryptFile(path, encFilePath)
  .then(() => conceal.decryptFile(encFilePath, decFilePath))
  .then(() => {
    console.log('done');
  })
  .catch((err) => {
    console.log(err);
  });

Using is Browser

<script src="https://cdn.jsdelivr.net/npm/almond@0.3.3/almond.min.js"></script>
<script src="./facebook-conceal.bundle.js"></script>

<script>
  const { Conceal } = require('facebook-conceal');
  const conceal = new Conceal('my-password');

  (async () => {
    const plain = 'hello world @ 2020';
    const encrypted = await conceal.encryptStr(plain);
    const decrypted = await conceal.decryptStr(encrypted);
  })();
</script>