Secure Text Encryption And Decryption Library – Encriptor.js

Category: Javascript , Text | April 8, 2024
AuthorSH20RAJ
Last UpdateApril 8, 2024
LicenseMIT
Tags
Views46 views
Secure Text Encryption And Decryption Library – Encriptor.js

The Encriptor.js text encryption/decryption library transforms plain text into an encrypted format that is virtually impenetrable without the correct decryption key.

This gives you the ability to safeguard login credentials, financial data, private communications, and any other vital information your users entrust to your application.

Beyond its primary encryption and decryption capabilities, EncriptorJS also includes a unique function for shuffling strings. This can be useful for obfuscating content, generating unique identifiers, or creating randomized text for games and interactive features.

How to use it:

1. Install and import the Encriptor.js.

# NPM
$ npm install encriptorjs
import Encriptor from 'encriptorjs';
// OR
import Encriptor from './encriptor.module.js';
<!-- Browser -->
<script src="encriptor.js"></script>

2. Encrypt text using the encrypt() method. This method requires two parameters: the text to be encrypted and an optional key for added security. Using digits in the key parameter is recommended for optimal security. The method then returns the encrypted text, which can only be decrypted with the correct key.

const text = 'CSSScript';
const key = '1111'; // default: 20
const encryptedText = Encriptor.encrypt(text, key);
// => Pdddzx1ia

3. Decrypt the encrypted text using the decrypt() method.

const encryptedText = 'Pdddzx1ia';
const key = '1111';
const decryptedText = Encriptor.decrypt(encryptedText, key);
// => 'Pdddzx1ia'

4. EncriptorJS also offers a shuffleString function that can be used to rearrange characters within a string using a key. This function takes the text and an optional key to initialize the randomization process. Using the same key consistently will produce the same shuffled output. While this can be used for basic encryption, it’s important to note that it doesn’t offer the same level of security as established encryption algorithms. For situations requiring robust encryption, it’s recommended to explore dedicated encryption libraries and algorithms.

const text = 'CSSScript';
const shuffledText = Encriptor.shuffleString(text, 25);

5. Additionally, the library provides the shuffle() function which will always generate a different shuffled pattern for the given text.

Encriptor.shuffle(text)

You Might Be Interested In:


Leave a Reply