https://github.com/ghosind/node-encoding
Data encoding functions for Node.js.
https://github.com/ghosind/node-encoding
base32 data-encoding javascript nodejs npm-package typescript
Last synced: 27 days ago
JSON representation
Data encoding functions for Node.js.
- Host: GitHub
- URL: https://github.com/ghosind/node-encoding
- Owner: ghosind
- License: mit
- Created: 2023-03-15T03:39:32.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2025-12-25T03:32:07.000Z (3 months ago)
- Last Synced: 2025-12-25T04:25:11.962Z (3 months ago)
- Topics: base32, data-encoding, javascript, nodejs, npm-package, typescript
- Language: TypeScript
- Homepage:
- Size: 138 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# @antmind/encoding
[](https://github.com/ghosind/node-encoding)
[](https://img.shields.io/npm/v/%40antmind%2Fencoding)
[](https://github.com/ghosind/node-encoding)
[](https://codecov.io/gh/ghosind/node-encoding)
[](https://github.com/ghosind/node-encoding)
Lightweight data encoding utilities for Node.js and browsers.
## Features
- Base32 encoding/decoding.
- Node.js and browser compatible.
## Installation
Install from npm:
```bash
npm install @antmind/encoding
```
## Quick Start
Encode and decode Base32 strings with default settings:
```js
import { base32 } from '@antmind/encoding';
// encode
const encoded = base32.encode('foo');
// => 'MZXW6==='
// decode
const decoded = base32.decode('MZXW6===');
// => 'foo'
```
You can also create a custom Base32 encoding instance with your own alphabet and padding character:
```js
import { Base32Encoding } from '@antmind/encoding';
const customBase32 = new Base32Encoding({
encoder: 'ABCDEFGHIJKLMNOPQRSTUVWXYZ234567', // standard Base32 alphabet
padChar: '*', // custom padding character
});
const encoded = customBase32.encode('foo');
// => 'MZXW6***'
// or method override
const encoded2 = customBase32.encode('foo', { padChar: '+' });
// => 'MZXW6+++'
```
## API
- `new Base32Encoding(options?: Base32Options)`
- `options.encoder?: string` — 32-character alphabet string. Defaults to `Base32StdEncoder`.
- `options.padChar?: string` — padding character (set to empty string `''` to disable padding). Defaults to `'='`.
- `encode(data: string, options?: Base32Options)` — Encodes `data` to a Base32 string. Accepts the same `options` as the constructor to override encoder/pad for a single call.
- `decode(str: string, options?: Base32Options)` — Decodes a Base32 `str` to the original string. Accepts the same `options` to override encoder/pad.
## Tests
Run the test suite with:
```bash
npm test
```
## Contributing
Contributions and bug reports are welcome. Please open issues or pull requests.
## License
This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.