!! THIS REPO HAS MOVED EOS-Nation/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.
npm
$ npm install --save eos-encrypt
import { encrypt, decrypt } from 'eos-encrypt';
const public_key = "EOS6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV";
const private_key = "5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3";
const message = "Private Message, shhhh!";
const encrypted = encrypt(private_key, public_key, message);
// => TO DECRYPT: eos-communication
// .1167451677...23460624..862584768Q+h1AeLQbjfzZJD1Nsx6kk3U/jSNStwoWstz9uNCadw=
const decrypted = decrypt(private_key, public_key, encrypted);
// => Private Message, shhhh!
Encrypt Message
private_key
string EOSIO Private Keypublic_key
string EOSIO Public Keymessage
string Message to Encryptmaxsize
number Maximum character message size (optional, default256
)
const encrypted = encrypt(private_key, public_key, message);
Returns string Encrypted Message
Decrypt Message
private_key
string EOSIO Private Keypublic_key
string EOSIO Public Keymessage
string Encrypted Message
const decrypted = decrypt(private_key, public_key, message);
Returns string Decrypted Message