npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

seablockjs

v1.0.2

Published

A library for multi-layered encryption called SEA(simple encryption algorithm)

Downloads

33

Readme

seaBlock 🌊📦

MIT License Version Beta Maintenance Awesome No Drama

Early Stage

seaBlock is a very simple and easy-to-use layered data encryption library that simplifies data encyption using the - SEA(Simple Encryption Algorithm). SEA is a layered Encryption Algorithm that use custom depth means layer order or layer sequence to encrypt or decrypt data . it is Designed for anyone who need a very simple fast and efficient way to handle data encryption.THIS IS JUST A VERY SIMPLE PROJECT FOR ME CAN BE USED IN VERY SIMPLE ENVIRONMENTS WHERE VERY LITTLE ENCRYPTION IS REQUIRED LIKE SOME BASIC STAIC SITES OR VERY SIMPLE PROJECTS

Table of Contents

Installation

To install the latest version of seablockjs, you can use NPM:

npm install seablockjs

Getting Started

Here's a quick tutorial to help you get started with seaBlock.

Importing SEA

First, import the library into your js project(app.js):

import { SEA, Sonar } from './node_modules/seablockjs/seablock.js'

const sea = new SEA();
const sonar = new Sonar();

and in HTML link the script you are working in like this

<script src="app.js" type= "module">
  • SEA class

    The SEA class is the main class of the library. It provides methods for encrypting and decrypting .

  • Sonar class

    The Sonar class is a helper class that provides methods for generating DEPTH for more random and dyanmic , complex encryption . Depth should always be secure and private because using the depth we can encrypt and decrypt the data

FEATURES

1. Multi-Layered Encryption

  • The SEA library supports up to five layers of encryption, each offering a unique data transformation method. This multi-layered approach enhances the security of the encrypted data.

2. Customizable Encryption Depth

  • Users can define the order of the encryption layers using the depth() method, allowing for flexible and customizable encryption processes.if a developer want to add morecomplexity to the geration of depth they can use the Sonar for Dynamic and complex depth/layer generation

3. Depth

  • The SEA allows users to apply multiple layers of encryption to their data. Each "depth" corresponds to one layer of encryption. For example, if the depth is set to 3123, the data will go through 4 different encryption processes, one after the other, according to the sequence defined by the user. The Sonar class provides a method for generating a dynamic and complex depth, which can be used to enhance the encryption process.

Example: Depth 3123

  • Layer 3: The first encryption layer applied will be based on the algorithm or method defined as "Layer 3."
  • Layer 1: Next, the data will be encrypted using the method defined as "Layer 1."
  • Layer 2: After that, "Layer 2" will be applied as the third encryption layer.
  • Layer 3: Finally, the data will be encrypted again using "Layer 3," completing the four layers of encryption.

So, the data undergoes encryption in the order specified by the depth value. In this case, the sequence is 3 → 1 → 2 → 3. This adds a customized and potentially more secure approach to encrypting data by allowing different combinations of encryption layers.

4. Reversible Encryption

  • All layers of encryption in the SEA library are fully reversible, enabling secure decryption through the unGuard() method and using the same depth that was used for encryption .

5. Various Encryption layers

  • Reverse Order: Reverses the order of the characters in the input data.
  • Shift Characters: Shifts characters forward by one position in the alphabet or digit sequence.
  • Substitute Characters: Substitutes characters based on a fixed pattern.
  • Caesar Cipher: Shifts characters by a specified number of positions (default is 3).
  • Mirror Alphabet: Mirrors characters across the alphabet (e.g., 'a' becomes 'z', 'b' becomes 'y').

more layers would be add in future we have a goal to add upto 20 different layers`

6, Sonar

  • The Sonar class is a helper class that provides methods for generating DEPTH for more random and dynamic , complex encryption . Depth should always be secure and private because using the depth we can encrypt and decrypt the data .
  • Why Sonar is Used:

      Randomization of Encryption Depth:
    
      Sonar generates a random number that dictates the depth or sequence of encryption layers in the SEA library. This adds an element of unpredictability to the encryption process, making it more secure.
      Dynamic Encryption:
    
      Instead of manually setting a fixed depth for encryption, Sonar allows the depth to be dynamically generated. This means each time you encrypt a message, the depth can change, leading to a unique encryption process every time.
      Customization of Encryption Layers:
    
      The random number generated by Sonar could be a sequence like 3123, which tells the SEA library to encrypt the data in the order of Layer 3 → Layer 1 → Layer 2 → Layer 3. By varying this sequence, you can customize how the data is encrypted, making it harder for unauthorized parties to decrypt without the correct sequence.

7. Security through Complexity

  • The layered encryption approach combined with character shifting, substitution, and mirroring techniques ensures a basic level of security. The complexity of the encryption increases with the number of layers used.

8. Symmetric Operations

  • The SEA library operations are symmetric, meaning the same process that encrypts data can be reversed to decrypt it.

Usage Examples

Without Sonar

Without using Sonar, you can manually set a fixed depth value for encryption with the SEA library. This means the encryption layers will be predetermined and consistent each time you encrypt data. Here's a simplified approach:

  • Initialization

    import { SEA } from './node_modules/seablockjs/seablock.js'
    // Import or initialize the SEA class
    let sea = new SEA();

    SEA Initialization: This creates an instance of the SEA class that will handle the encryption and decryption processes.

  • Set a Fixed Depth


// Set a fixed depth value in SEA
const fixedDepth = 3123;  // Example depth value it can be of any character length till 5000 
sea.depth(fixedDepth);

SEA.depth(fixedDepth): This method sets a constant depth value for the SEA instance. The depth value determines the sequence and number of encryption layers applied to the data. For example, a depth of 3123 means:

Layer 3: The first encryption layer applied will be based on the method defined as "Layer 3."

Layer 1: Next, the data will be encrypted using "Layer 1."

Layer 2: After that, "Layer 2" will be applied.

Layer 3: Finally, "Layer 3" will be applied again.
  • Encrypt the Message

// Original message to encrypt
const message = 'Hello, hi I am SEA !!';

// Encrypt the message using the SEA class
const encryptedMessage = sea.guard(message);
console.log('Encrypted Message:', encryptedMessage);

SEA.guard(message): Encrypts the original message using the layers defined by the fixed depth. It processes the message through the specified encryption layers and returns the encrypted result.

  • Decrypt the Message

// Decrypt the message to verify the encryption process
const decryptedMessage = sea.unGuard(encryptedMessage);
console.log('Decrypted Message:', decryptedMessage);

SEA.unGuard(encryptedMessage): Decrypts the encrypted message. It applies the decryption layers in the reverse order of the depth sequence, reversing the encryption process.

  • Verification

// Verify that the decrypted message matches the original
console.log('Decryption successful:', decryptedMessage === message);
  Purpose:
  To confirm that the decryption process correctly restores the original message. This ensures that encryption and decryption are functioning as expected with the fixed depth.

With Sonar

import { SEA, Sonar } from './node_modules/seablockjs/seablock.js'

// Import or initialize the SEA and Sonar class

let sea = new SEA();
let sonar = new Sonar();

// Original message to encrypt
const message = 'Hello, hi I am SEA !!';

// Generate a random number using Sonar for setting the depth
sonar.range(120);  // Set the number of digits to generate
let depth = sonar.activate();  // Generate the final random number
console.log(depth);

// Set the depth in SEA using the generated random number
sea.depth(depth);

// Encrypt the message using the SEA class
const encryptedMessage = sea.guard(message);
console.log('Encrypted Message:', encryptedMessage);

// Decrypt the message to verify the encryption process
const decryptedMessage = sea.unGuard(encryptedMessage);
console.log('Decrypted Message:', decryptedMessage);

// Verify that the decrypted message matches the original
console.log('Decryption successful:', decryptedMessage === message);

Initialization


// Import or initialize the SEA and Sonar class
let sea = new SEA();
let sonar = new Sonar();
  • SEA Initialization: The SEA class is initialized to handle encryption and decryption. It will be used to apply multiple layers of encryption based on a dynamic depth value.

  • Sonar Initialization: The Sonar class is initialized to generate a random number that will determine the encryption depth for the SEA class.

  • Original Message


// Original message to encrypt
const message = 'Hello, hi I am SEA !!';

Purpose: This is the plaintext message that you want to encrypt. It will be processed by the SEA class to produce an encrypted version.

  • Generate Random Depth

// Generate a random number using Sonar for setting the depth
sonar.range(120);  // Set the number of digits to generate
let depth = sonar.activate();  // Generate the final random number
console.log(depth);
Sonar.range(120):

This method sets the number of digits that Sonar will use to generate a random number. The range value defines how many digits will be used in the generated random number.

  • Sonar.activate():

    This method generates the final random number based on the set range. This number will be used to determine the encryption depth in the SEA class.
    
    Purpose:
    To create a unique and unpredictable depth value that will be used to customize the encryption layers in the SEA class.
  • Set Depth in SEA


// Set the depth in SEA using the generated random number
sea.depth(depth);
  • SEA.depth(depth):

    This method sets the encryption depth for the SEA instance. The depth value (a sequence of numbers) determines the order in which different encryption layers will be applied to the data.
    Purpose:
    
    To configure the SEA class with a dynamic depth value so that the encryption process is customized based on the generated random number.
  • Encrypt the Message


// Encrypt the message using the SEA class
const encryptedMessage = sea.guard(message);
console.log('Encrypted Message:', encryptedMessage);

SEA.guard(message):

  This method encrypts the provided message using the layers defined by the set depth. It processes the message through the specified encryption layers and returns the encrypted result.
  Purpose:

  To apply the encryption based on the dynamically generated depth and produce an encrypted version of the original message.
  • Decrypt the Message

// Decrypt the message to verify the encryption process
const decryptedMessage = sea.unGuard(encryptedMessage);
console.log('Decrypted Message:', decryptedMessage);

SEA.unGuard(encryptedMessage):

  This method decrypts the previously encrypted message. It reverses the encryption process by applying the decryption layers in the reverse order of the depth sequence.
  Purpose:

  To verify that the encryption and decryption process works correctly and that the original message can be accurately recovered from the encrypted data.
  • Verification

// Verify that the decrypted message matches the original
console.log('Decryption successful:', decryptedMessage === message);
  Purpose:
  To ensure that the decryption process has correctly restored the original message. This confirms that the encryption and decryption processes are functioning as intended.

Sonar:

Used to dynamically generate a random number that determines the encryption depth for the SEA class. This adds complexity and uniqueness to the encryption process.

SEA:

Handles the encryption and decryption of the message based on the depth value set by Sonar. It applies multiple layers of encryption to securely transform the message. By using Sonar to generate the encryption depth and SEA to apply the encryption and decryption, the code ensures a robust and dynamic approach to securing the message.

Contributing

We welcome contributions from the community! but yet library is not fully secure and complete that why we are on hold for any further contributions

License

This project is licensed under the MIT License - see the LICENSE file for details.