JWT Secret Generator

A simple, secure, and lightweight JWT secret key generator for Node.js applications. Generate cryptographically strong random keys perfect for signing JSON Web Tokens.

JWT Secret Generator πŸ”

npm versionarrow-up-right License: MITarrow-up-right Node.js Versionarrow-up-right

πŸš€ Features

  • Cryptographically Secure: Uses Node.js crypto.randomBytes() for true randomness

  • Flexible Length: Generate secrets from 128-bit to 512-bit strength

  • Multiple Encodings: Support for hex, base64, and base64url encoding

  • Batch Generation: Generate multiple secrets at once

  • Zero Dependencies: Pure Node.js implementation

  • TypeScript Ready: Includes type definitions

πŸ“¦ Installation

npm install jwt-secret-generator

πŸ”§ Usage

Basic Usage

Generate by Bit Strength

Batch Generation

Using Aliases

πŸ›‘οΈ Security Best Practices

When using JWT secrets arrow-up-rightin production:

  1. Use Strong Secrets: Always use at least 256-bit secrets for production

  2. Environment Variables: Store secrets in environment variables, never in code

  3. Regular Rotation: Rotate secrets periodically

  4. Secure Storage: Use secure key management services in production

πŸ“š API Reference

generateJWTSecret(length?, encoding?)

Generate a secure JWT secret key.arrow-up-right

  • length (number, optional): Length in bytes (default: 32)

  • encoding (string, optional): Output encoding - 'hex', 'base64', 'base64url' (default: 'hex')

  • Returns: String - The generated secret

generateJWTSecretByBits(bits?, encoding?)

Generate a secret by bit strength.

  • bits (number, optional): Bit strength - 128, 256, 384, 512 (default: 256)

  • encoding (string, optional): Output encoding (default: 'hex')

  • Returns: String - The generated secret

generateMultipleJWTSecrets(count?, length?, encoding?)

Generate multiple secrets at once.

  • count (number, optional): Number of secrets to generate (default: 1)

  • length (number, optional): Length in bytes (default: 32)

  • encoding (string, optional): Output encoding (default: 'hex')

  • Returns: Array - Array of generated secrets

🌟 Why Choose This Package?

  • Security First: Uses cryptographically secure random number generation

  • Production Ready: Battle-tested algorithms and best practices

  • Developer Friendly: Simple API with sensible defaults

  • Lightweight: Zero dependencies, minimal footprint

  • Well Documented: Comprehensive documentation and examples

  • 🌐 Online JWT Secret Generator: jwtsecrets.comarrow-up-right - Generate JWT secrets online with our web tool

  • πŸ“š Awesome JWT Resources: Awesome JWT Listarrow-up-right - Curated list of JWT libraries, tools and resources

  • πŸ“– JWT.io: Learn more about JSON Web Tokens

  • πŸ”’ OWASP JWT Security: Best practices for JWT security

🀝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like change.

πŸ“„ License

This project is licensed under the MIT License - see the LICENSEarrow-up-right file for details.

πŸ™ Acknowledgments

  • Built with ❀️ for the developer community

  • Inspired by the need for secure JWT implementations

  • Thanks to all contributors and users


Need more JWT tools? Check out our comprehensive JWT toolkitarrow-up-right and awesome JWT resourcesarrow-up-right!

Readme

Keywords

Package Sidebar

Install

npm i jwt-secret-generator

Repository

github.com/huang-hub/Awesome-JWT-Listarrow-up-right

Homepage

jwtsecrets.com/arrow-up-right

Version

1.0.0

License

MIT

Unpacked Size

8.34 kB

Total Files

3

Issues

0arrow-up-right

Pull Requests

0arrow-up-right

Last publish

a day ago

Collaborators

Try on RunKitReport malware

Last updated