EOS Encrypt
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
examples Init repo Oct 3, 2018
types Init repo Oct 3, 2018
.gitignore Init repo Oct 3, 2018
LICENSE Initial commit Oct 3, 2018
README.md Update docs Oct 3, 2018
index.ts Update docs Oct 3, 2018
package.json v1.0.1 Oct 3, 2018
test.ts Update docs Oct 3, 2018
tsconfig.json Update docs Oct 3, 2018
tslint.json Init repo Oct 3, 2018
yarn.lock Init repo Oct 3, 2018

README.md

EOS Encrypt

Allows to encrypt & decypt a message with an EOS key pair using AES shared key encryption mechanism.

Decryption is achieved by combining the receiver's private key and the sender's public key to create the private key necessary to decrypt the message.

This module uses eosjs-ecc to perform the required cryptographic operations.

Install

npm

$ npm install --save eos-encrypt

Usage

import { encrypt, decrypt } from 'eos-encrypt';

const public_key = "EOS6M...DW5CV";
const private_key = "5KQwr...zkvFD3";

const message = "Private Message, shhhh!";
const encrypted = encrypt(private_key, public_key, message);
// => TO DECRYPT: eos-encrypt
// .1167451677...23460624..862584768Q+h1AeLQbjfzZJD1Nsx6kk3U/jSNStwoWstz9uNCadw=

const decrypted = decrypt(private_key, public_key, encrypted);
// => Private Message, shhhh!

API

Table of Contents

encrypt

Encrypt Message

Parameters

  • private_key string EOSIO Private Key
  • public_key string EOSIO Public Key
  • message string Message to Encrypt
  • options object Optional parameters (optional, default {})
    • options.memo string Serialized Memo (optional, default "TO DECRYPT: eos-encrypt\n")
    • options.maxsize number Maximum character message size (optional, default 256)

Examples

const encrypted = encrypt(private_key, public_key, message);

Returns string Encrypted Message

decrypt

Decrypt Message

Parameters

  • private_key string EOSIO Private Key
  • public_key string EOSIO Public Key
  • message string Encrypted Message
  • options object Optional parameters (optional, default {})
    • options.memo string Serialized Memo (optional, default "TO DECRYPT: eos-encrypt\n")

Examples

const decrypted = decrypt(private_key, public_key, message);

Returns string Decrypted Message

setMemo

Set Default Memo

Parameters

Examples

setMemo("TO DECRYPT: my-dapp\n");

Returns void