base53-encoder
Version:
A unique Base53 encoding scheme with 30-bit block and 5-bit segment encoding
118 lines (79 loc) • 2.29 kB
Markdown
`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.
- 🔢 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
Install the package using npm:
```bash
npm install base53-encoder
```
```javascript
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!'
```
```javascript
// 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
```
```javascript
// Custom key generation
const customKey = Base53.buildKey(
3, // Number of segments
24 // Length of each segment
);
```
- **Encoding Table**: 32 unique characters
- **Segment Size**: 5 bits
- **Block Size**: 30 bits (6 segments)
- **Padding**: Automatic padding to ensure full block encoding
- Mimics Base64 encoding
- Custom 5-bit segment approach
- Flexible key generation
- Built-in error handling
The library throws an error for invalid encoded strings:
```javascript
try {
Base53.decode('Invalid&Characters');
} catch (error) {
console.error('Encoding error:', error.message);
}
```
`base53-encoder` is designed to be lightweight and efficient, with minimal overhead for encoding and decoding operations.
- Node.js v14.16+
- ESM module support
Contributions are welcome! Please feel free to submit a Pull Request.
MIT License
[] Nate
- encoding
- base53
- encryption
- key-generation
```