Dokumentacja API

advertisement

Dokumentacja API

Wprowadzenie

Nasze wszechstronne API RESTful umożliwia łatwy programowy dostęp do klasycznych algorytmów szyfrowania, w tym szyfru Cezara, transformacji ROT13 oraz wieloalfabetowego szyfru Vigenère'a. Zostało zaprojektowane specjalnie z myślą o edukacji i jest całkowicie darmowe dla studentów, nauczycieli, programistów oraz miłośników kryptografii. Bez względu na to, czy tworzysz aplikacje edukacyjne, prowadzisz badania, czy po prostu eksplorujesz fascynujący świat historycznej kryptografii, nasze API oferuje zaawansowane funkcje z inteligentnymi możliwościami automatycznego łamania szyfrów oraz obsługą wielu języków i niestandardowych alfabetów.

Adres bazowy: https://caesar-cipher.com/api/v1

Typ zawartości: application/json

Limit żądań: 60 żądań/minutę

Kluczowe zalety

Nasze API wyróżnia się edukacyjnym podejściem, kompleksową dokumentacją oraz przyjaznym dla programistów designem. Wszystkie endpointy zwracają szczegółowe odpowiedzi z kontekstem edukacyjnym, co czyni je idealnymi dla środowisk nauki. Wbudowana analiza częstotliwości oraz automatyczne łamanie szyfrów dostarczają cennych wglądów w techniki kryptoanalizy.

🎓 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

Treść żądania:

{
  "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
}

Odpowiedź:

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

Odszyfruj tekst

POST /api/v1/caesar/decrypt

Treść żądania:

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

Odpowiedź:

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

Automatyczne łamanie szyfru Cezara

POST /api/v1/caesar/solve

Treść żądania:

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

Odpowiedź:

{
  "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"
}

Przetwarzanie masowe

POST /api/v1/caesar/bulk

Treść żądania:

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

Odpowiedź:

{
  "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

Przekształć tekst

POST /api/v1/rot13/transform

Treść żądania:

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

Odpowiedź:

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

Masowe ROT13

POST /api/v1/rot13/bulk

Treść żądania:

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

Odpowiedź:

{
  "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"}
  ]
}

Szyfr Vigenère'a

Szyfrowanie Vigenère'a

POST /api/v1/vigenere/encrypt

Treść żądania:

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

Odpowiedź:

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

Analiza i łamanie Vigenère'a

POST /api/v1/vigenere/analyze

Treść żądania:

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

Odpowiedź:

{
  "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
}

Przykłady kodu

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"

Obsługa błędów

API używa standardowych kodów statusu HTTP i zwraca komunikaty błędów w formacie JSON.

Popularne kody statusu:

  • 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

Format odpowiedzi błędu:

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

Limity żądań

API jest ograniczone do 60 żądań na minutę na adres IP. Informacje o limitach są zawarte w nagłówkach odpowiedzi:

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"
}

W celu uzyskania wyższych limitów lub użytku komercyjnego, prosimy skorzystać z formularza kontaktowego na naszej stronie.

Gotowy na start?

Zacznij eksplorować nasze API już dziś! Testuj endpointy bezpośrednio, integruj je ze swoimi aplikacjami lub skorzystaj z naszych interaktywnych narzędzi webowych, aby lepiej zrozumieć klasyczną kryptografię.