EOS Encrypt
github: https://github.com/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.
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 Keypublic_key
string EOSIO Public Keymessage
string Message to Encryptoptions
object Optional parameters (optional, default{}
)
Examples
const encrypted = encrypt(private_key, public_key, message);
Returns string Encrypted Message
decrypt
Decrypt Message
Parameters
private_key
string EOSIO Private Keypublic_key
string EOSIO Public Keymessage
string Encrypted Messageoptions
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
memo
string Set Memo
Examples
setMemo("TO DECRYPT: my-dapp\n");
Returns void
版权属于:区块链中文技术社区 / 转载原创者
本文链接:https://bcskill.com/index.php/archives/572.html
相关技术文章仅限于相关区块链底层技术研究,禁止用于非法用途,后果自负!本站严格遵守一切相关法律政策!