Data Encryption For Node Based Project

Published 29 May 2023

The increase in development of information technology and the rapid growth in internet banking and shopping have seamlessly made electronic payment grown increasingly high over the last few decades and that has become a driving force to increase the use of E-commerce services which has led to high spike of internet users.

  1. The aim of this project give a detailed implementation and installation of this library to further increase the confidentiality of data stored in Database.
  2. Click on getstarted to begin the public and private key generation, the .pem file downloaded should be kept safe expecially the private key.
step 1

Before we begin this library support only backend running NodeJS server

NPM LetSecure package
step 2

This library support SSR -Server Side Rendereing application eg Express based based arch and other frameworks built on top nodeJS

step 3

Install the library into the node based backend project and companion front-end application, by doing so your 50% ahead encrypting your data.

step 4

The code snippet below show how to use this library inside your project

First Implementation - Encryption

 
        import { encryptData } from "@letsecure/encryptmydata";
        import path from "path";
        
        
        encryptData({
          incomingData: <PLAIN_DATA_TO_BE_ENCRYPTED>,
          //your private key to sign the message has signature
          relativeOrAbsolutePathToPrivateKey:path.resolve(PATH_TO_STORED_PRIVATE_KEY_FILE),
          //sender's public key to encrypt the message
          relativeOrAbsolutePathToPublicKey:path.resolve(PATH_TO_STORED_PUBLIC_KEY_FILE),
          passphase: "PASSPHRASE_FOR_YOUR_ENCRYPTION",
          cb: ({ data, signature }) => {
            return (payload = {
              data,
              signature,
            });
          },
        });
       
        
                
        

Second Implementation - Decryption


        import { decryptData } from "@letsecure/encryptmydata";

        //descypt the key here using duo library
        const { data, verified } = decryptData({
        EncryptedData: encryptedData,
        passphase: keys.secretAccessKey,
        //your private key to reveal the data
        relativeOrAbsolutePathToPrivateKey: keys.privateKey,
        //sender's public key to validate the signature
        relativeOrAbsolutePathToPublicKey: keys.publicKey,
        signature,
  });      
         //verify digital signature
         if(!verified) throw new Error('data tampered')
         
        
End to End encryption
Tosin Owoeye

Tosin Owoeye

Web Engineer & Blockchain Developer