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_toolkit by Zexson Team
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:
Store keys in environment variables:
- Place your cryptographic keys in a
.envfile. This file should not be included in your version control system (e.g., Git). - Example:
ENCRYPTION_KEY=my-secret-key
- Place your cryptographic keys in a
Use dotenv for secure key management:
- Install
dotenvif 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.
- Install
Rotate keys regularly:
- Regularly update your encryption keys to prevent potential unauthorized access. Document key rotations in your system for audit purposes.
Limit key permissions:
- Restrict access to keys by limiting the permissions of the
.envfile 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.
- Restrict access to keys by limiting the permissions of the
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): stringbase64Decode(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): EncryptableObjectdecryptObject(object: EncryptableObject, secretKey?: string): EncryptableObject
π€ Contributing
Contributions are welcome! Hereβs how you can contribute:
- Submit issues to report bugs or suggest features.
- Create pull requests to improve the toolkit.
- 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.