Skip to content

A cryptographically strong pseudo-random string generator using only the native Node.js crypto module.

License

Notifications You must be signed in to change notification settings

przpl/node-native-random-string

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

node-native-random-string

NPM version NPM downloads NPM bundle size

Description

A cryptographically strong pseudo-random string generator using only the native Node.js crypto module.

  • TypeScript support
  • Lightweight - no external dependencies
  • Uses randomBytes() and randomInt() functions from the native crypto module
  • Generates random numeric (decimal), hexadecimal, and base64 strings

Requirements

  • Node.js v18.0.0 or higher

Examples

Random numeric string

import { randomNumeric } from "node-native-random-string";

const numericString = randomNumeric(10); // random 10-digit numeric string

Random hexadecimal string

import { randomHex } from "node-native-random-string";

const hexString = randomHex(16); // random 16-character hexadecimal string

Random base64 string

import { randomBase64 } from "node-native-random-string";

const base64String = randomBase64(32); // random 32-character base64 string

About

A cryptographically strong pseudo-random string generator using only the native Node.js crypto module.

Resources

License

Stars

Watchers

Forks

Packages

No packages published