New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

base53-encoder

Package Overview
Dependencies
Maintainers
0
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

base53-encoder

A unique Base53 encoding scheme with 30-bit block and 5-bit segment encoding

latest
npmnpm
Version
1.0.1
Version published
Maintainers
0
Created
Source

base53-encoder

Overview

base53-encoder is a unique Base53 encoding scheme that provides a flexible and innovative approach to string encoding and key generation. Inspired by traditional base encoding methods, this library offers a custom 30-bit block encoding strategy with 5-bit segments.

Features

  • 🔢 Custom 32-character encoding table
  • 🧩 5-bit segment encoding
  • 🔒 Flexible key generation
  • 🔄 Robust encode and decode methods
  • 🚀 Lightweight and easy to use
  • 🌐 ESM module support

Installation

Install the package using npm:

npm install base53-encoder

Usage

Basic Encoding and Decoding

import Base53 from 'base53-encoder';

// Encode a string
const encoded = Base53.encode('Hello, World!');
console.log(encoded);

// Decode a string
const decoded = Base53.decode(encoded);
console.log(decoded); // 'Hello, World!'

Key Generation

// Generate a 150-bit key
const key = Base53.buildKey();

console.log(key.rawKey);      // Original random key
console.log(key.encodedKey);  // Encoded key
console.log(key.decodedKey);  // Decoded key

Customizing Key Generation

// Custom key generation
const customKey = Base53.buildKey(
  3,    // Number of segments 
  24    // Length of each segment
);

Encoding Strategy

Technical Details

  • Encoding Table: 32 unique characters
  • Segment Size: 5 bits
  • Block Size: 30 bits (6 segments)
  • Padding: Automatic padding to ensure full block encoding

Unique Characteristics

  • Mimics Base64 encoding
  • Custom 5-bit segment approach
  • Flexible key generation
  • Built-in error handling

Error Handling

The library throws an error for invalid encoded strings:

try {
  Base53.decode('Invalid&Characters');
} catch (error) {
  console.error('Encoding error:', error.message);
}

Performance

base53-encoder is designed to be lightweight and efficient, with minimal overhead for encoding and decoding operations.

Compatibility

  • Node.js v14.16+
  • ESM module support

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

MIT License

Author

[Your Name] Nate

Keywords

  • encoding
  • base53
  • encryption
  • key-generation

Keywords

encoding

FAQs

Package last updated on 23 Jan 2025

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