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

random-char-gen

Package Overview
Dependencies
Maintainers
0
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

random-char-gen

Here’s the `README.md` file for your package:

latest
npmnpm
Version
1.1.3
Version published
Weekly downloads
5
Maintainers
0
Weekly downloads
 
Created
Source

Here’s the README.md file for your package:

random-char-gen

A simple and efficient utility to generate random alphanumeric strings and numeric OTPs. Perfect for applications that require unique codes or secure one-time passwords.

Installation

Install the package via npm:

npm install random-char-gen

Features

  • Generate random alphanumeric strings of customizable lengths.
  • Generate numeric OTPs of any specified length.

Usage

Import the package and call the desired function:

Generate a Random Alphanumeric String

const { generateRandomChar } = require('random-char-gen');

// Generate a random string of 10 characters
const randomString = generateRandomChar(10);
console.log(randomString); // Example output: 'aBcDeF123G'

Generate a Numeric OTP

const { generateOTP } = require('random-char-gen');

// Generate a 6-digit OTP
const otp = generateOTP(6);
console.log(otp); // Example output: '123456'

API Reference

generateRandomChar(length)

  • Description: Generates a random alphanumeric string.
  • Parameters:
    • length (number): The length of the string to generate.
  • Returns: A string containing random alphanumeric characters.

generateOTP(length)

  • Description: Generates a numeric one-time password (OTP).
  • Parameters:
    • length (number): The length of the OTP to generate.
  • Returns: A string containing random numeric characters.

Example

const { generateRandomChar, generateOTP } = require('random-char-gen');

// Generate a random string of 8 characters
const randomStr = generateRandomChar(8);
console.log(`Random String: ${randomStr}`); // Example: 'Ab12Cd34'

// Generate a 4-digit OTP
const oneTimePassword = generateOTP(4);
console.log(`OTP: ${oneTimePassword}`); // Example: '5678'

License

This package is licensed under the ISC License. See the LICENSE file for details.

Author

Arvind Varma
For queries or contributions, please contact arvind@example.com.

Feel free to adjust the contact information or add more details if necessary.

FAQs

Package last updated on 24 Dec 2024

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