@puraty/short-id-generator
v1.0.1
Published
Simple and secure short ID generator using Node's crypto module.
Downloads
6
Maintainers
Readme
@puraty/short-id-generator
Simple, secure, and URL-safe short ID generation utility for Node.js.
Installation
npm install @puraty/short-id-generatoror
yarn add @puraty/short-id-generatorUsage
The library exports a single function, generateShortId.
import { generateShortId } from '@your-username/short-id-generator';
// Generate a default 10-character ID
const shortId = generateShortId();
console.log(shortId); // Example: 'aBcD123XyZ'
// Generate a custom 16-character ID
const customId = generateShortId(16);
console.log(customId); // Example: 'HjKLMnOP45678901'API Reference
generateShortId(length?: number): string
Generates a cryptographically secure, URL-safe random ID string.
| Parameter | Type | Default | Description |
| :--- | :--- | :--- | :--- |
| length | number | 10 | The desired length of the ID. |
Returns: A secure, alphanumeric, URL-safe string.
License
This project is licensed under the ISC License. See the LICENSE file for details.
Contributing
Feel free to open issues or submit pull requests to improve this utility!
