ETEvoraTools
Password & Token Tools

Secure PIN Generator

Secure PIN Generator creates digits using crypto.getRandomValues and rejection sampling, with requested length constrained from 4 to 32. It provides unbiased numeric generation, but a PIN remains a low-alphabet secret whose safety depends heavily on attempt limits, device binding, storage, and context.

Runs locally — files stay on your device
Quick answer

How many possibilities does a random six-digit PIN have?

One million, from 000000 through 999999; leading zeroes are valid in this generator.

A PIN is a string of digits, not necessarily a number

For n independently uniform decimal digits, there are 10^n possible strings. Treating the result as a number can discard leading zeroes and reduce the representation.

How it works

Choose a digit count. The browser samples random bytes, maps them without modulo bias to 0–9, and joins the digits; lengths below four or above 32 are clamped.

Key concepts

Leading zeroes matter

004281 is a six-digit PIN and should remain a string.

Rate limiting is essential

Even uniform short PIN spaces can be exhausted without attempt controls.

When to use it

  • Create a random temporary numeric code.
  • Generate a local test PIN.
  • Demonstrate numeric search-space growth.

When not to use it

  • Do not use a short PIN without strict retry limits.
  • Do not store or transmit it in plain text.
  • Do not assume the page provisions, expires, or binds the code to a user.

Worked examples

Six digits

Input
Length 6
Expected output
A string from 000000 to 999999

Every six-digit sequence is available.

Minimum clamp

Input
Length 2
Expected output
4 digits

The implementation enforces at least four.

Long numeric token

Input
Length 16
Expected output
16 random digits

Storage must preserve leading zeroes.

Common mistakes

Parsing as an integer

Leading zeroes disappear. Correction: Store PINs as strings.

Allowing unlimited attempts

A small search space becomes easy to enumerate. Correction: Rate-limit, lock, expire, and monitor verification.

Calling generation a full OTP system

The page has no binding, delivery, expiry, or verification state. Correction: Use an authenticated server-side flow.

Best practices

  • Use short expiry and strict attempt limits.
  • Store only an appropriate protected verifier.
  • Bind codes to a purpose and account.

Related operations and differences

Password Generator

Choose Password Generator when you need to generate a secure random password locally.; use Secure PIN Generator specifically for pin.

Basic Auth Header Generator

Choose Basic Auth Header Generator when you need to generate a Basic Authorization header locally.; use Secure PIN Generator specifically for pin.

HMAC Generator

Choose HMAC Generator when you need to create an HMAC using the browser Web Crypto API.; use Secure PIN Generator specifically for pin.

JWT Expiration Checker

Choose JWT Expiration Checker when you need to inspect the exp claim in a JWT.; use Secure PIN Generator specifically for pin.

JWT Header Viewer

Choose JWT Header Viewer when you need to decode a JWT header without verifying its signature.; use Secure PIN Generator specifically for pin.

JWT Payload Viewer

Choose JWT Payload Viewer when you need to decode a JWT payload without verifying its signature.; use Secure PIN Generator specifically for pin.

Limitations and privacy

  • Generates text only.
  • No delivery, expiration, storage, verification, throttling, or user binding.
  • Device compromise can expose the result.

The entered value is processed locally in this browser. Avoid using an untrusted device for real credentials or secrets.

Frequently asked questions

Can a PIN start with zero?

Yes.

Is the output cryptographically random?

It uses crypto.getRandomValues.

Does it expire automatically?

No.

Does it enforce retry limits?

No.