Encryption & Decryption

TRON DAO
TRON
Published in
2 min readOct 31, 2019

Introduction

This guide walks the user through how to programmatically perform encryption/decryption by using the eccrypto library.

Install the eccrypto library by running:

Encryption

In this example, we will use an existing public key from a randomly generated public-private key pair to encrypt a simple text file containing “Hello BTFS”. Later, we will decrypt this file.

The encrypt.js program:

Run the program by inputting the Input File Name, Encrypted File Name, and the Public Key, where:

Input File Name = The file name in your current directory to be encrypted.
Encrypted File Name = Designate the name for the encrypted file.
Public Key = The public key used to encrypt the file.

Decryption

To decrypt the file we just encrypted, run the following program by inputting the Encrypted File Name, Decrypted File Name, and Private Key, where:

Encrypted File Name = The name of the encrypted file located in your current directory.
Decrypted File Name = Designate the name for the decrypted file.
Private Key = The private key associated with the public key used to encrypt the file.

The output:

--

--