🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

encryptjs

Package Overview
Dependencies
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

encryptjs

A library to encrypt and decrypt a string

2.0.0
latest
Source
npm
Version published
Weekly downloads
171
3.01%
Maintainers
1
Weekly downloads
 
Created
Source

encryptjs

A library to encrypt and decrypt a string

usuage:

      npm install encryptjs --save-dev     in your project folder

Import the module using require command

      var encrypt=require('encryptjs');

To encrypt the string , we need a plain text and a "secret key", the same "secret key" is used to decrypt the cipher text.

      var secretkey='ios';
      var plaintext='apple';
      var cipherText =encrypt.encrypt(plaintext,secretkey,256);
      console.log(cipherText+" ****************** ");
      var decipher=encrypt.decrypt(cipherText,secretkey,256);
      console.log("Deciphered Text is : "+decipher);
      

To get the string from console , encrypt & write to a text file :

      var secretkey='ios';
      var filePath="./encrypted.txt";
      encrypt.getTextEncryptAndSaveToTextFile(filePath,secretkey,256);
      

Enter the text to be encrypted in console prompt, ciphred text will be saved in your given file path as ".txt" format

To get the string from console, encrypt & write to a JSON file :

      var secretkey='ios';
      var filePath="./encryptedData.JSON";
      encrypt.getTextEncryptAndSaveToJSONFile(filePath,secretkey,256);
      

Enter the text to be encrypted in console.prompt, ciphred text will be saved in your given file path as ".JSON" format

Common method to decrypt the cipher text in both cases.

      var decipher=encrypt.decrypt(cipherText,secretkey,256);

      

Available functions:

      encrypt(plaintext,secretkey,bit): To encrypt the string 
      decrypt(ciphertext,secretkey,bit): To decrypt the string 
      getTextEncryptAndSaveToTextFile(filePath,secretkey,bit): Gets text from command line, encrypts & writes to Text file
      getTextEncryptAndSaveToJSONFile(filePath,secretkey,bit): Gets text from command line, encrypts & writes to JSON file 

Bit value can be 128, 192 & 256

Keywords

AES

FAQs

Package last updated on 20 Oct 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts