w

API Referansı

Genel Bakış

MD5 hash hesaplayıcısı, metin hesaplama, dosya işleme ve toplu işlemleri destekleyen tam bir RESTful API arayüzü sağlar.

Temel Bilgiler

  • Temel URL: https://api.example.com/md5
  • Kimlik Doğrulama: API Anahtarı
  • Veri Formatı: JSON
  • Karakter Kodlaması: UTF-8

Yanıt Formatı

Tüm API yanıtları birleşik bir formatı takip eder:

{
  "success": true,
  "data": {
    // Belirli veriler
  },
  "message": "İşlem başarılı",
  "timestamp": "2024-01-20T10:30:00Z"
}

Metin MD5 Hesaplama

Metin MD5 Hesaplama

Uç Nokta: POST /api/md5/text

İstek Parametreleri:

{
  "text": "Hesaplanacak metin içeriği",
  "encoding": "utf8",
  "outputFormat": "hex"
}

Parametre Açıklaması:

ParametreTipGerekliAçıklama
textstringEvetHesaplanacak metin içeriği MD5
encodingstringHayırKarakter kodlaması, varsayılan utf8
outputFormatstringHayırÇıktı formatı, varsayılan hex

Desteklenen Kodlama Formatları:

  • utf8: UTF-8 kodlaması
  • ascii: ASCII kodlaması
  • utf16: UTF-16 kodlaması
  • gbk: GBK kodlaması

Desteklenen Çıktı Formatları:

  • hex: Küçük harf onaltılık
  • hex-upper: Büyük harf onaltılık
  • base64: Base64 kodlaması

Yanıt Örneği:

{
  "success": true,
  "data": {
    "text": "Hello, World!",
    "hash": "65a8e27d8879283831b664bd8b7f0ad4",
    "encoding": "utf8",
    "outputFormat": "hex",
    "length": 32
  },
  "message": "Hesaplama başarılı",
  "timestamp": "2024-01-20T10:30:00Z"
}

Toplu Metin Hesaplama

Uç Nokta: POST /api/md5/text/batch

İstek Parametreleri:

{
  "texts": ["Metin1", "Metin2", "Metin3"],
  "encoding": "utf8",
  "outputFormat": "hex"
}

Yanıt Örneği:

{
  "success": true,
  "data": {
    "results": [
      {
        "text": "Metin1",
        "hash": "hash1",
        "index": 0
      },
      {
        "text": "Metin2",
        "hash": "hash2",
        "index": 1
      },
      {
        "text": "Metin3",
        "hash": "hash3",
        "index": 2
      }
    ],
    "total": 3,
    "encoding": "utf8",
    "outputFormat": "hex"
  },
  "message": "Toplu hesaplama başarılı",
  "timestamp": "2024-01-20T10:30:00Z"
}

Dosya MD5 Hesaplama

Yüklenen Dosya Hesaplama

Uç Nokta: POST /api/md5/file

İstek Formatı: multipart/form-data

İstek Parametreleri:

ParametreTipGerekliAçıklama
filefileEvetHesaplanacak dosya
outputFormatstringHayırÇıktı formatı, varsayılan hex

Yanıt Örneği:

{
  "success": true,
  "data": {
    "filename": "example.txt",
    "size": 1024,
    "hash": "d41d8cd98f00b204e9800998ecf8427e",
    "outputFormat": "hex",
    "processingTime": 150
  },
  "message": "Dosya hesaplama başarılı",
  "timestamp": "2024-01-20T10:30:00Z"
}

Toplu Dosya Hesaplama

Uç Nokta: POST /api/md5/file/batch

İstek Formatı: multipart/form-data

İstek Parametreleri:

ParametreTipGerekliAçıklama
filesfileEvetHesaplanacak dosyalar dizisi
outputFormatstringHayırÇıktı formatı, varsayılan hex

Yanıt Örneği:

{
  "success": true,
  "data": {
    "results": [
      {
        "filename": "file1.txt",
        "size": 1024,
        "hash": "hash1",
        "processingTime": 150
      },
      {
        "filename": "file2.txt",
        "size": 2048,
        "hash": "hash2",
        "processingTime": 200
      }
    ],
    "total": 2,
    "totalSize": 3072,
    "totalTime": 350
  },
  "message": "Toplu dosya hesaplama başarılı",
  "timestamp": "2024-01-20T10:30:00Z"
}

Hash Değeri Doğrulama

Hash Değeri Doğrulama

Uç Nokta: POST /api/md5/verify

İstek Parametreleri:

{
  "text": "Doğrulanacak metin",
  "expectedHash": "Beklenen hash değeri",
  "encoding": "utf8"
}

Yanıt Örneği:

{
  "success": true,
  "data": {
    "text": "Hello, World!",
    "expectedHash": "65a8e27d8879283831b664bd8b7f0ad4",
    "calculatedHash": "65a8e27d8879283831b664bd8b7f0ad4",
    "isValid": true,
    "encoding": "utf8"
  },
  "message": "Doğrulama başarılı",
  "timestamp": "2024-01-20T10:30:00Z"
}

Dosya Bütünlüğü Doğrulama

Uç Nokta: POST /api/md5/verify/file

İstek Formatı: multipart/form-data

İstek Parametreleri:

ParametreTipGerekliAçıklama
filefileEvetDoğrulanacak dosya
expectedHashstringEvetBeklenen hash değeri

Yanıt Örneği:

{
  "success": true,
  "data": {
    "filename": "example.txt",
    "expectedHash": "d41d8cd98f00b204e9800998ecf8427e",
    "calculatedHash": "d41d8cd98f00b204e9800998ecf8427e",
    "isValid": true,
    "size": 1024
  },
  "message": "Dosya bütünlüğü doğrulama başarılı",
  "timestamp": "2024-01-20T10:30:00Z"
}

Hata Yönetimi

Hata Yanıt Formatı

{
  "success": false,
  "error": {
    "code": "ERROR_CODE",
    "message": "Hata açıklaması",
    "details": "Detaylı hata bilgisi"
  },
  "timestamp": "2024-01-20T10:30:00Z"
}

Yaygın Hata Kodları

Hata KoduAçıklamaHTTP Durum Kodu
INVALID_INPUTGeçersiz giriş parametreleri400
FILE_TOO_LARGEDosya çok büyük413
UNSUPPORTED_ENCODINGDesteklenmeyen kodlama formatı400
INVALID_HASH_FORMATGeçersiz hash formatı400
RATE_LIMIT_EXCEEDEDİstek sıklığı sınırı aşıldı429
INTERNAL_ERRORSunucu iç hatası500

Kullanım Örnekleri

JavaScript Örneği

// Metin MD5 hesaplama
const calculateTextMD5 = async (text) => {
  const response = await fetch('/api/md5/text', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
      Authorization: 'Bearer YOUR_API_KEY',
    },
    body: JSON.stringify({
      text,
      encoding: 'utf8',
      outputFormat: 'hex',
    }),
  });

  const result = await response.json();
  return result.data.hash;
};

// Dosya MD5 hesaplama
const calculateFileMD5 = async (file) => {
  const formData = new FormData();
  formData.append('file', file);

  const response = await fetch('/api/md5/file', {
    method: 'POST',
    headers: {
      Authorization: 'Bearer YOUR_API_KEY',
    },
    body: formData,
  });

  const result = await response.json();
  return result.data.hash;
};

// Hash değeri doğrulama
const verifyHash = async (text, expectedHash) => {
  const response = await fetch('/api/md5/verify', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
      Authorization: 'Bearer YOUR_API_KEY',
    },
    body: JSON.stringify({
      text,
      expectedHash,
      encoding: 'utf8',
    }),
  });

  const result = await response.json();
  return result.data.isValid;
};

Python Örneği

import requests
import json

# Metin MD5 hesaplama
def calculate_text_md5(text, api_key):
    url = "https://api.example.com/md5/text"
    headers = {
        "Content-Type": "application/json",
        "Authorization": f"Bearer {api_key}"
    }
    data = {
        "text": text,
        "encoding": "utf8",
        "outputFormat": "hex"
    }

    response = requests.post(url, headers=headers, json=data)
    result = response.json()

    if result["success"]:
        return result["data"]["hash"]
    else:
        raise Exception(result["error"]["message"])

# Dosya MD5 hesaplama
def calculate_file_md5(file_path, api_key):
    url = "https://api.example.com/md5/file"
    headers = {
        "Authorization": f"Bearer {api_key}"
    }

    with open(file_path, 'rb') as file:
        files = {'file': file}
        response = requests.post(url, headers=headers, files=files)

    result = response.json()

    if result["success"]:
        return result["data"]["hash"]
    else:
        raise Exception(result["error"]["message"])

# Hash değeri doğrulama
def verify_hash(text, expected_hash, api_key):
    url = "https://api.example.com/md5/verify"
    headers = {
        "Content-Type": "application/json",
        "Authorization": f"Bearer {api_key}"
    }
    data = {
        "text": text,
        "expectedHash": expected_hash,
        "encoding": "utf8"
    }

    response = requests.post(url, headers=headers, json=data)
    result = response.json()

    if result["success"]:
        return result["data"]["isValid"]
    else:
        raise Exception(result["error"]["message"])

cURL Örneği

# Metin MD5 hesaplama
curl -X POST "https://api.example.com/md5/text" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -d '{
    "text": "Hello, World!",
    "encoding": "utf8",
    "outputFormat": "hex"
  }'

# Dosya MD5 hesaplama
curl -X POST "https://api.example.com/md5/file" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -F "file=@example.txt"

# Hash değeri doğrulama
curl -X POST "https://api.example.com/md5/verify" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -d '{
    "text": "Hello, World!",
    "expectedHash": "65a8e27d8879283831b664bd8b7f0ad4",
    "encoding": "utf8"
  }'

Sınırlamalar

İstek Sınırlamaları

  • Metin uzunluğu: Maksimum 10MB
  • Dosya boyutu: Maksimum 100MB
  • Toplu miktar: Maksimum 100 öğe
  • İstek sıklığı: Dakikada maksimum 1000 istek

Desteklenen Formatlar

  • Metin kodlaması: UTF-8, ASCII, UTF-16, GBK
  • Çıktı formatı: Onaltılık (büyük/küçük harf), Base64
  • Dosya türleri: Tüm dosya türleri

Son Güncelleme: 20 Ocak 2024

Was this page helpful?