Documentación API

advertisement

Documentación API

Comenzando

Nuestra completa API RESTful proporciona acceso programático perfecto a diversas operaciones de cifrado clásico, incluyendo el cifrado César, la transformación ROT13 y el cifrado polialfabético Vigenère. Diseñada específicamente para fines educativos, esta API es completamente gratuita y perfecta para estudiantes, educadores, desarrolladores y entusiastas de la criptografía. Ya sea que estés construyendo aplicaciones educativas, realizando investigación o simplemente explorando el fascinante mundo de la criptografía histórica, nuestra API ofrece funcionalidad robusta con capacidades inteligentes de resolución automática y soporte para múltiples idiomas y alfabetos personalizados.

URL base: https://caesar-cipher.com/api/v1

Tipo de contenido: application/json

Límite de solicitudes: 60 solicitudes/minuto

Beneficios Clave

Nuestra API se destaca por su enfoque educativo, documentación completa y diseño amigable para desarrolladores. Todos los endpoints devuelven respuestas detalladas con contexto educativo, haciéndola perfecta para entornos de aprendizaje. El análisis de frecuencia integrado y las capacidades automáticas de ruptura de cifrados proporcionan valiosos conocimientos sobre técnicas de criptoanálisis.

🎓 Educational Focus

Designed specifically for learning environments with comprehensive educational context and examples.

🔍 Auto-Solving

Intelligent frequency analysis and automatic cipher-breaking capabilities for research and learning.

🌍 Multi-Language

Support for multiple alphabets including Polish, German, Spanish, French, and custom alphabets.

📚 Free & Open

Completely free for educational and research purposes with comprehensive documentation.

Caesar Cipher

Encrypt Text

POST /api/v1/caesar/encrypt

Cuerpo de la solicitud:

{
  "text": "Hello World",
  "shift": 3,
  "alphabet": "basic",  // optional: basic, polish, german, spanish, french, custom
  "custom_alphabet": "ABCDEFGHIJKLMNOPQRSTUVWXYZ",  // required if alphabet is "custom"
  "preserve_case": true,  // optional, default: true
  "preserve_non_alpha": true  // optional, default: true
}

Respuesta:

{
  "success": true,
  "result": "Khoor Zruog",
  "method": "encrypt",
  "shift": 3,
  "alphabet": "basic",
  "text_length": 11
}

Descifrar texto

POST /api/v1/caesar/decrypt

Cuerpo de la solicitud:

{
  "text": "Khoor Zruog",
  "shift": 3,
  "alphabet": "basic"
}

Respuesta:

{
  "success": true,
  "result": "Hello World",
  "method": "decrypt",
  "shift": 3,
  "alphabet": "basic",
  "text_length": 11
}

Resolver cifrado César automáticamente

POST /api/v1/caesar/solve

Cuerpo de la solicitud:

{
  "text": "Khoor Zruog",
  "alphabet": "basic",  // optional
  "language": "en"  // optional: en, pl, de, es, fr
}

Respuesta:

{
  "success": true,
  "best_solution": {
    "shift": 3,
    "text": "Hello World",
    "confidence": 95
  },
  "all_solutions": [
    {"shift": 3, "text": "Hello World", "score": 95.2},
    {"shift": 7, "text": "Dahhk Sknhz", "score": 42.1},
    ...
  ],
  "alphabet": "basic",
  "language": "en"
}

Procesamiento masivo

POST /api/v1/caesar/bulk

Cuerpo de la solicitud:

{
  "items": [
    {"text": "Hello", "shift": 3},
    {"text": "World", "shift": 5}
  ],
  "method": "encrypt",  // encrypt, decrypt, or solve
  "alphabet": "basic"
}

Respuesta:

{
  "success": true,
  "method": "encrypt",
  "alphabet": "basic",
  "count": 2,
  "results": [
    {"index": 0, "original": "Hello", "result": "Khoor", "shift": 3},
    {"index": 1, "original": "World", "result": "Btwqi", "shift": 5}
  ]
}

ROT13

Transformar texto

POST /api/v1/rot13/transform

Cuerpo de la solicitud:

{
  "text": "Hello World",
  "preserve_case": true,
  "preserve_non_alpha": true
}

Respuesta:

{
  "success": true,
  "result": "Uryyb Jbeyq",
  "method": "rot13",
  "text_length": 11
}

ROT13 masivo

POST /api/v1/rot13/bulk

Cuerpo de la solicitud:

{
  "items": ["Hello", "World", "ROT13"],
  "preserve_case": true
}

Respuesta:

{
  "success": true,
  "method": "rot13",
  "count": 3,
  "results": [
    {"index": 0, "original": "Hello", "result": "Uryyb"},
    {"index": 1, "original": "World", "result": "Jbeyq"},
    {"index": 2, "original": "ROT13", "result": "EBG13"}
  ]
}

Cifrado Vigenère

Cifrar con Vigenère

POST /api/v1/vigenere/encrypt

Cuerpo de la solicitud:

{
  "text": "Hello World",
  "key": "KEY",
  "preserve_case": true,
  "preserve_non_alpha": true
}

Respuesta:

{
  "success": true,
  "result": "Rijvs Uyvjn",
  "method": "encrypt",
  "key_length": 3,
  "text_length": 11
}

Analizar y romper Vigenère

POST /api/v1/vigenere/analyze

Cuerpo de la solicitud:

{
  "text": "RIJVS UYVJN RIJVS UYVJN...", // Long encrypted text
  "max_key_length": 10  // optional, default: 10
}

Respuesta:

{
  "success": true,
  "analysis": {
    "probable_key_lengths": [3, 6, 9],
    "best_key_length": 3,
    "ioc_scores": {"1": 0.043, "2": 0.045, "3": 0.065},
    "probable_key": "KEY",
    "decrypted_preview": "HELLO WORLD HELLO WORLD..."
  },
  "text_length": 100
}

Ejemplos de código

JavaScript / Node.js

// Caesar Cipher Encryption
const response = await fetch('https://caesar-cipher.com/api/v1/caesar/encrypt', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    text: 'Hello World',
    shift: 3,
    alphabet: 'basic'
  })
});

const data = await response.json();
console.log(data.result); // "Khoor Zruog"

Python

import requests

# ROT13 Transform
response = requests.post('https://caesar-cipher.com/api/v1/rot13/transform',
    json={
        'text': 'Hello World',
        'preserve_case': True
    })

data = response.json()
print(data['result'])  # "Uryyb Jbeyq"

cURL

# Vigenère Cipher Encryption
curl -X POST https://caesar-cipher.com/api/v1/vigenere/encrypt \
  -H "Content-Type: application/json" \
  -d '{
    "text": "Hello World",
    "key": "SECRET",
    "preserve_case": true
  }'

PHP

// Caesar Cipher Solver
$data = [
    'text' => 'Khoor Zruog',
    'alphabet' => 'basic',
    'language' => 'en'
];

$options = [
    'http' => [
        'header'  => "Content-type: application/json\r\n",
        'method'  => 'POST',
        'content' => json_encode($data)
    ]
];

$context  = stream_context_create($options);
$result = file_get_contents('https://caesar-cipher.com/api/v1/caesar/solve', false, $context);
$response = json_decode($result, true);

echo $response['best_solution']['text']; // "Hello World"

Manejo de errores

La API utiliza códigos de estado HTTP estándar y devuelve mensajes de error JSON.

Códigos de estado comunes:

  • 200 OK - Request successful
  • 400 Bad Request - Invalid parameters
  • 422 Unprocessable Entity - Validation errors
  • 429 Too Many Requests - Rate limit exceeded
  • 500 Internal Server Error - Server error

Formato de respuesta de error:

{
  "success": false,
  "error": "Validation error",
  "errors": {
    "text": ["The text field is required."],
    "shift": ["The shift must be between -25 and 25."]
  }
}

Limitación de solicitudes

La API está limitada a 60 solicitudes por minuto por dirección IP. La información sobre límites se incluye en los encabezados de respuesta:

X-RateLimit-Limit: 60
X-RateLimit-Remaining: 58

# When rate limit is exceeded (HTTP 429):
{
  "error": "Too Many Requests",
  "message": "Rate limit exceeded. You can make up to 60 requests per minute.",
  "retry_after": 60,
  "documentation": "https://caesar-cipher.com/api-docs"
}

Para límites más altos o uso comercial, por favor use el formulario de contacto en nuestro sitio web.

¿Listo para comenzar?

¡Comienza a explorar nuestra API hoy mismo! Prueba los endpoints directamente, integra las funciones en tus aplicaciones o utiliza nuestras herramientas web interactivas para comprender mejor la criptografía clásica.