Generador de par de claves RSA
Genera al instante pares de claves RSA pública y privada en tu navegador. Longitudes de 512 a 8192 bits, formato PEM (PKCS#8 / X.509). Compatible con OpenSSL, SSH, JWT y SSL/TLS. No se requiere inicio de sesión. Las claves no salen de tu navegador.
Default: 2048 bits
Validación de clave PEM
Pegue una clave PEM pública o privada para comprobar si es válida.
Cómo usar
Acerca de esta herramienta
Utiliza este generador de par de claves RSA cuando necesites una clave pública y privada para desarrollo, SSH, TLS o experimentos con JWT. Elige un tamaño de clave, como 2048 bits para pruebas cotidianas o 4096 bits cuando quieras un par más robusto, y luego exporta en PEM adecuado para flujos de trabajo estilo OpenSSL (clave privada PKCS#8 y clave pública X.509). La generación se ejecuta completamente en tu navegador. Tus claves se crean en tu dispositivo y no se suben a los servidores de Handy Dev Tools, algo importante cuando manejas material privado, incluso en uso que no sea de producción. La herramienta es gratuita y no requiere cuenta. Trata las claves generadas como credenciales de desarrollo, a menos que sigas tu propio proceso seguro de gestión de claves. Prefiere 2048 bits o más para pruebas realistas, y mantén las claves privadas fuera del control de versiones y de chats compartidos.
Cómo usar
1. When you open the page, a key pair is automatically generated with the default (2048 bits), and the public and private keys are displayed. 2. To change key length: Enter a value that is a multiple of 8 between 512 and 8192 bits in the key length field, then click "Generate". 3. To generate a new key pair with the same key length: Click the "Regenerate" button. 4. Copy keys: Click the copy button in each key's display area to copy to the clipboard. 5. Download keys: Click the download button in each key's display area to download as a PEM file (public key: public_key.pem, private key: private_key.pem).
Opciones
Key length: Must be between 512 and 8192 bits and a multiple of 8. Default is 2048 bits. Use the up/down buttons in the number input to increment/decrement by 8. Invalid values (out of range or not a multiple of 8) show an error message and disable the "Generate" and "Regenerate" buttons.
Casos de uso
• Generating key pairs for SSH connections (public key authentication setup) • Creating private keys for SSL/TLS certificates • Generating key pairs for JWT signing • Creating key pairs for encrypted communication • Temporary key pair generation for development and testing • Generating key pairs for code signing
Ejemplos de código
1// Generate key pair
2const keyPair = await window.crypto.subtle.generateKey(
3 {
4 name: 'RSA-OAEP',
5 modulusLength: 2048,
6 publicExponent: new Uint8Array([1, 0, 1]), // 65537
7 hash: 'SHA-256',
8 },
9 true, // extractable
10 ['encrypt', 'decrypt']
11);1from cryptography.hazmat.primitives.asymmetric import rsa
2from cryptography.hazmat.primitives import serialization
3
4# Generate key pair
5private_key = rsa.generate_private_key(
6 public_exponent=65537,
7 key_size=2048
8)
9public_key = private_key.public_key()
10
11# Export in PEM format
12private_pem = private_key.private_bytes(
13 encoding=serialization.Encoding.PEM,
14 format=serialization.PrivateFormat.PKCS8,
15 encryption_algorithm=serialization.NoEncryption()
16)
17public_pem = public_key.public_bytes(
18 encoding=serialization.Encoding.PEM,
19 format=serialization.PublicFormat.SubjectPublicKeyInfo
20)1# Generate 2048-bit RSA private key
2openssl genrsa -out private_key.pem 2048
3
4# Extract public key
5openssl rsa -in private_key.pem -pubout -out public_key.pem1# Clave pública PEM → formato OpenSSH de una línea (authorized_keys)
2ssh-keygen -f public_key.pem -i -m PKCS8 > openssh_public.pub
3
4# Comprobar la clave privada
5openssl rsa -in private_key.pem -check -noout
6
7# Crear CSR desde la clave privada (añada -subj para no interactivo)
8openssl req -new -key private_key.pem -out csr.pem1$config = [
2 'private_key_bits' => 2048,
3 'private_key_type' => OPENSSL_KEYTYPE_RSA,
4];
5$key = openssl_pkey_new($config);
6openssl_pkey_export($key, $privatePem);
7$details = openssl_pkey_get_details($key);
8$publicPem = $details['key'];
9
10// openssl_pkey_export may emit PKCS#1 (BEGIN RSA PRIVATE KEY)
11// depending on OpenSSL/PHP. This tool exports PKCS#8 (BEGIN PRIVATE KEY).1// .env — store file paths, never paste PEM contents
2// JWT_ALGO=RS256
3// JWT_PRIVATE_KEY=file:///var/www/certs/private_key.pem
4// JWT_PUBLIC_KEY=file:///var/www/certs/public_key.pem
5
6// Laravel Passport
7// php artisan passport:keys
8// Or copy this tool's PEM to storage/oauth-private.key
9// and storage/oauth-public.keyHow it works
RSA key pair generation prioritizes the Web Crypto API. If Web Crypto API is unavailable or PEM conversion fails, it falls back to the node-forge library. Keys are PEM: private keys in PKCS#8 (-----BEGIN PRIVATE KEY-----), public keys as X.509 SubjectPublicKeyInfo (-----BEGIN PUBLIC KEY-----). Larger key lengths take longer to generate, but a 2048-bit key pair typically completes within 5 seconds. All processing is done in the browser; keys are never sent to any server.
Privacidad y datos
All key generation is done in the browser; generated public and private keys are never sent to any server. Keys exist only in browser memory and are not automatically saved. Private keys are sensitive — manage them carefully and clear them from memory (e.g., close the browser) when done. Do not paste private keys into FAQ answers, chat, or source code. For production, prefer generating keys in a secure, isolated environment when possible.
Preguntas frecuentes
- Q: ¿Qué es un par de claves RSA?
- A: Un par de claves RSA es una clave pública y su correspondiente clave privada, utilizadas para cifrado, firma, SSH, TLS y JWT. La clave pública se puede compartir; la clave privada debe mantenerse en secreto.
- Q: ¿Qué tamaño de clave debo usar?
- A: Usa 2048 bits para desarrollo y pruebas generales. Prefiere 4096 bits cuando necesites mayor seguridad. Evita tamaños muy pequeños (por ejemplo, 512) fuera de experimentos con sistemas heredados.
- Q: ¿Se suben mis claves a un servidor?
- A: No. La generación se ejecuta en tu navegador. Las claves no se envían a los servidores de Handy Dev Tools.
- Q: ¿Qué formatos puedo exportar?
- A: Salida PEM adecuada para flujos de trabajo estilo OpenSSL (clave privada PKCS#8 / clave pública X.509). Cópiala o descárgala para uso local.
- Q: ¿Es gratis?
- A: Sí. No se requiere registro.
- Q: ¿Cómo genero el mismo par de claves en PHP?
- A: Usa openssl_pkey_new() con OPENSSL_KEYTYPE_RSA y una longitud como 2048, luego openssl_pkey_export() para la clave privada y openssl_pkey_get_details() para la pública. Consulta el ejemplo PHP de esta página. openssl_pkey_export() puede emitir PKCS#1 (BEGIN RSA PRIVATE KEY) según OpenSSL/PHP; esta herramienta exporta PKCS#8 (BEGIN PRIVATE KEY). Ambos se aceptan ampliamente.
- Q: ¿Puedo usar estas claves con Laravel JWT o Passport?
- A: Sí para desarrollo. Esta herramienta exporta claves privadas PKCS#8 y públicas X.509 (SPKI), que aceptan Laravel Passport y librerías JWT RS256 (p. ej. tymon/jwt-auth). Apunta JWT_PRIVATE_KEY / JWT_PUBLIC_KEY a los archivos PEM, o cópialos a storage/oauth-private.key y storage/oauth-public.key para Passport. No subas claves privadas al control de versiones.
