JSPM

zexson_toolkit

1.1.1
    • ESM via JSPM
    • ES Module Entrypoint
    • Export Map
    • Keywords
    • License
    • Repository URL
    • TypeScript Types
    • README
    • Created
    • Published
    • Downloads 7
    • Score
      100M100P100Q36682F
    • License MIT

    A powerful encryption and token generation library that provides secure string encryption, decryption and random token generation with customizable character sets. Perfect for creating secure tokens, passwords and encrypted data.

    Package Exports

    • zexson_toolkit
    • zexson_toolkit/dist/index.js

    This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (zexson_toolkit) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

    Readme

    Zexson Team Logo

    zexson_toolkit by Zexson Team

    Zexson Team Website

    License Version Downloads Discord Donate via

    A powerful encryption and token generation library developed by the Zexson Team.


    πŸš€ Features

    • Advanced Encryption/Decryption

      • Custom encryption algorithm with random padding
      • Base64 encoding with character shifting
      • Key-based encryption support
    • Token Generation

      • Customizable length and character sets
      • Multiple predefined character set options
      • High entropy random generation
    • String Comparison

      • Case-sensitive and case-insensitive comparison
      • Encrypted string comparison
      • Detailed comparison results

    πŸ“¦ Installation

    Install the package via npm:

    npm install zexson_toolkit

    πŸ”§ Usage

    Crypt Example Function

    import { cryptExample } from 'zexson_toolkit'
    cryptExample('zexson_toolkit','zexson_team')

    Basic Encryption/Decryption

    import { encrypt, decrypt } from 'zexson_toolkit'
    
    // Basic encryption
    const encrypted = encrypt("sensitive data")
    const decrypted = decrypt(encrypted)

    Advanced Encryption with Options

    import { encrypt } from 'zexson_toolkit'
    
    // Custom encryption with options
    const encrypted = encrypt("sensitive data", {
      firstRandomCharSet: 'set1',
      secondRandomCharSet: 'set2',
      key: 'customKey'
    })

    Token Generation

    import { tokenGenerator } from 'zexson_toolkit'
    
    // Generate a token with specified length and character set
    const token = tokenGenerator(16, 'defaultSet')

    String Comparison

    import { isEqual } from 'zexson_toolkit'
    
    // Compare strings with options
    const result = isEqual("text1", "text2", {
      caseSensitive: false,
      key: "customKey",
      log: true
    })

    Base64 Encoding/Decoding

    import { base64Encode, base64Decode } from 'zexson_toolkit'
    
    // Encode a string
    const encoded = base64Encode("example string", "customKey")
    
    // Decode a string
    const decoded = base64Decode(encoded, "customKey")

    Object Encryption/Decryption

    import { encryptObject, decryptObject } from 'zexson_toolkit'
    
    // Encrypt an object
    const data = { username: "JohnDoe", password: "12345" }
    const encryptedData = encryptObject(data, "my-secret-key")
    
    // Decrypt an object
    const decryptedData = decryptObject(encryptedData, "my-secret-key")

    Advanced Object Encryption/Decryption Examples

    import { encryptBody, decryptBody } from 'zexson_toolkit'
    
    // Encrypt an object with the encryptBody function
    const data = { username: "JohnDoe", password: "12345" }
    const encryptedData = encryptBody(data, "my-secret-key")
    
    // Decrypt the object with the decryptBody function
    const decryptedData = decryptBody(encryptedData, "my-secret-key")
    
    // Advanced encryption with complex data structure
    const complexData = { 
      username: "JohnDoe", 
      password: "12345", 
      about: { gender: 'male', age: 12 }, 
      hobbies: ['football', 'basketball', { football: true, basketball: false }] 
    }
    const encryptedComplexData = encryptBody(complexData, "my-secret-key")
    const decryptedComplexData = decryptBody(encryptedComplexData, "my-secret-key")

    Secure Key Management Recommendations

    For optimal security, it’s crucial to manage and store cryptographic keys carefully. Here’s a simple guide to help you maintain the integrity and security of your keys:

    1. Store keys in environment variables:

      • Place your cryptographic keys in a .env file. This file should not be included in your version control system (e.g., Git).
      • Example:
        ENCRYPTION_KEY=my-secret-key
    2. Use dotenv for secure key management:

      • Install dotenv if you haven't already:
        npm install dotenv
      • Load your environment variables in your application using dotenv:
        require('dotenv').config() || import * as dotenv from 'dotenv'; dotenv.config()
        const encryptionKey = process.env.ENCRYPTION_KEY
      • This ensures that the key is only accessible within your application's runtime, not hard-coded directly in the codebase.
    3. Rotate keys regularly:

      • Regularly update your encryption keys to prevent potential unauthorized access. Document key rotations in your system for audit purposes.
    4. Limit key permissions:

      • Restrict access to keys by limiting the permissions of the .env file and ensuring only authorized personnel can modify it.
      • Avoid placing keys directly in source code, as this can expose them in version history and logs.
    5. Encrypt sensitive data:

      • Whenever storing sensitive data, encrypt it with the appropriate keys to prevent unauthorized access if it’s compromised.

    πŸ“š Available Functions

    Encryption Functions

    • encrypt(data: string, options?: EncryptOptions): Promise<string>
    • decrypt(data: string, options?: DecryptOptions): Promise<string>
    • base64Encode(data: string, key?: string): string
    • base64Decode(data: string, key?: string): string

    Token Generation

    • tokenGenerator(length: number, type: CharacterSetType): string

    String Comparison

    • isEqual(text1: string, text2: string, options?: IsEqualOptions): Promise<{ isEqual: boolean, method?: string }>

    Object Encryption Functions

    • encryptObject(object: EncryptableObject, secretKey?: string): EncryptableObject
    • decryptObject(object: EncryptableObject, secretKey?: string): EncryptableObject

    🀝 Contributing

    Contributions are welcome! Here’s how you can contribute:

    1. Submit issues to report bugs or suggest features.
    2. Create pull requests to improve the toolkit.
    3. Share ideas to enhance functionality.

    πŸ“« Connect with Us


    πŸ“„ License Information

    This project is licensed under the MIT License. The MIT License is a permissive open-source license that allows users to freely use, modify, distribute, and sublicense the software, subject to certain conditions. For a full description of the terms and conditions under which this project can be used, modified, and distributed, please refer to the LICENSE file included in the project. By using, modifying, or distributing this project, you agree to abide by the terms outlined in the MIT License.


    Why Choose zexson_toolkit?

    • Clean and well-documented codebase.
    • Regular updates and active maintenance.
    • Tailored for developers needing advanced cryptographic utilities.

    Made with ❀️ for you by Zexson Team.