๐Ÿš€ SHA-224 Hash API

RESTful API Service for SHA-224 Hash Generation

Version 2.0 REST + WebSocket 99.9% Uptime

๐Ÿ“‹ API Overview

The SHA-224 Hash API provides a simple, secure, and scalable way to generate SHA-224 hashes for your applications. Perfect for data integrity verification, digital signatures, and secure storage.

Base URL

URL https://api.sha224.com/v2

Features

๐Ÿ” Authentication

API Key Required: All endpoints require authentication via API key. Get your free API key at sha224.com/api-key

Authentication Methods

1. Header Authentication (Recommended)

HTTP X-API-Key: your_api_key_here

2. Query Parameter

URL https://api.sha224.com/v2/hash?api_key=your_api_key_here

3. Bearer Token

HTTP Authorization: Bearer your_api_key_here

๐Ÿ“ API Endpoints

POST /hash Generate SHA-224 hash for text or data

Request Body

Parameter Type Required Description
data string Required The text or data to hash
encoding string Optional Input encoding: utf8 (default), base64, hex
output string Optional Output format: hex (default), base64, binary

Example Request

cURL
curl -X POST https://api.sha224.com/v2/hash \
  -H "X-API-Key: your_api_key" \
  -H "Content-Type: application/json" \
  -d '{
    "data": "Hello, World!",
    "encoding": "utf8",
    "output": "hex"
  }'

Response

JSON
{
  "success": true,
  "hash": "4149da18aa8bfc2b1e382c6c26556d01a92c261b6436dad5e3be3fcc",
  "algorithm": "SHA-224",
  "encoding": "hex",
  "timestamp": "2024-01-15T10:30:45.123Z",
  "processing_time_ms": 2
}
JSON
{
  "success": false,
  "error": {
    "code": "INVALID_INPUT",
    "message": "Data parameter is required",
    "details": "Request body must contain 'data' field"
  }
}
POST /batch Generate multiple SHA-224 hashes

Request Body

Parameter Type Required Description
items array Required Array of items to hash (max 1000)
parallel boolean Optional Process in parallel (default: true)

Example Request

cURL
curl -X POST https://api.sha224.com/v2/batch \
  -H "X-API-Key: your_api_key" \
  -H "Content-Type: application/json" \
  -d '{
    "items": [
      {"id": "1", "data": "First text"},
      {"id": "2", "data": "Second text"},
      {"id": "3", "data": "Third text"}
    ],
    "parallel": true
  }'
POST /file Hash uploaded file

Request

Parameter Type Required Description
file file Required File to hash (max 100MB)
chunk_size integer Optional Chunk size for processing (default: 1MB)

Example Request

cURL
curl -X POST https://api.sha224.com/v2/file \
  -H "X-API-Key: your_api_key" \
  -F "file=@/path/to/document.pdf"
POST /hmac Generate HMAC-SHA224

Request Body

Parameter Type Required Description
data string Required Data to authenticate
key string Required Secret key for HMAC
key_encoding string Optional Key encoding: utf8 (default), hex, base64
POST /verify Verify SHA-224 hash

Request Body

Parameter Type Required Description
data string Required Original data
hash string Required Hash to verify

Response

JSON
{
  "success": true,
  "valid": true,
  "message": "Hash verification successful",
  "expected_hash": "4149da18aa8bfc2b1e382c6c26556d01a92c261b6436dad5e3be3fcc",
  "provided_hash": "4149da18aa8bfc2b1e382c6c26556d01a92c261b6436dad5e3be3fcc"
}
POST /stream Stream large file hashing

For files larger than 100MB, use the streaming endpoint with chunked transfer encoding.

Example Request

Node.js
const fs = require('fs');
const https = require('https');

const fileStream = fs.createReadStream('large-file.bin');
const req = https.request({
  hostname: 'api.sha224.com',
  path: '/v2/stream',
  method: 'POST',
  headers: {
    'X-API-Key': 'your_api_key',
    'Transfer-Encoding': 'chunked',
    'Content-Type': 'application/octet-stream'
  }
});

fileStream.pipe(req);
req.on('response', (res) => {
  // Handle response
});

๐Ÿ”Œ WebSocket API

Real-time SHA-224 hashing via WebSocket connection for high-volume or streaming applications.

Connection

WebSocket wss://api.sha224.com/v2/ws?api_key=your_api_key

Message Format

JSON
// Client -> Server
{
  "action": "hash",
  "id": "unique-request-id",
  "data": "Text to hash",
  "options": {
    "encoding": "utf8",
    "output": "hex"
  }
}

// Server -> Client
{
  "id": "unique-request-id",
  "success": true,
  "hash": "4149da18aa8bfc2b1e382c6c26556d01a92c261b6436dad5e3be3fcc",
  "timestamp": "2024-01-15T10:30:45.123Z"
}

WebSocket Example

JavaScript
const ws = new WebSocket('wss://api.sha224.com/v2/ws?api_key=your_api_key');

ws.onopen = () => {
  console.log('Connected to SHA-224 WebSocket');

  // Send hash request
  ws.send(JSON.stringify({
    action: 'hash',
    id: Date.now().toString(),
    data: 'Hello, WebSocket!'
  }));
};

ws.onmessage = (event) => {
  const response = JSON.parse(event.data);
  console.log('Hash received:', response.hash);
};

ws.onerror = (error) => {
  console.error('WebSocket error:', error);
};

โฑ๏ธ Rate Limiting

Rate Limits: API requests are rate-limited based on your plan tier. Upgrade your plan for higher limits at sha224.com/pricing
Plan Requests/Second Requests/Day Max File Size WebSocket Connections
Free 10 1,000 10 MB 1
Basic 50 10,000 50 MB 5
Pro 200 100,000 100 MB 20
Enterprise Unlimited Unlimited 1 GB Unlimited

Rate Limit Headers

HTTP
X-RateLimit-Limit: 10
X-RateLimit-Remaining: 7
X-RateLimit-Reset: 1705318245
X-RateLimit-Retry-After: 60

๐Ÿ“ฆ Official SDKs

Use our official SDKs for quick integration with your favorite programming language.

๐Ÿ
Python
v2.1.0
๐Ÿ“œ
JavaScript
v2.0.3
๐Ÿน
Go
v1.5.0
โ˜•
Java
v2.0.1
๐Ÿ’Ž
Ruby
v1.3.0
๐Ÿ˜
PHP
v1.8.2

Installation Examples

Bash
# Python
pip install sha224-api

# JavaScript/Node.js
npm install @sha224/api-client

# Go
go get github.com/sha224/go-sdk

# Ruby
gem install sha224-api

# PHP
composer require sha224/api-client

โŒ Error Codes

HTTP Status Error Code Description
400 INVALID_INPUT Invalid or missing required parameters
401 UNAUTHORIZED Invalid or missing API key
401 EXPIRED_KEY API key has expired
429 RATE_LIMIT_EXCEEDED Too many requests
413 FILE_TOO_LARGE File exceeds maximum size limit
500 INTERNAL_ERROR Internal server error

Error Response Format

JSON
{
  "success": false,
  "error": {
    "code": "RATE_LIMIT_EXCEEDED",
    "message": "API rate limit exceeded",
    "details": "You have exceeded the rate limit of 10 requests per second",
    "retry_after": 60
  }
}

๐Ÿ’ก Complete Examples

Python Example

Python
import requests
import json

class SHA224Client:
    def __init__(self, api_key):
        self.api_key = api_key
        self.base_url = "https://api.sha224.com/v2"
        self.headers = {
            "X-API-Key": api_key,
            "Content-Type": "application/json"
        }

    def hash_text(self, text):
        """Generate SHA-224 hash for text"""
        response = requests.post(
            f"{self.base_url}/hash",
            headers=self.headers,
            json={"data": text}
        )
        return response.json()

    def hash_file(self, file_path):
        """Generate SHA-224 hash for file"""
        with open(file_path, 'rb') as f:
            response = requests.post(
                f"{self.base_url}/file",
                headers={"X-API-Key": self.api_key},
                files={"file": f}
            )
        return response.json()

    def batch_hash(self, items):
        """Generate multiple hashes"""
        response = requests.post(
            f"{self.base_url}/batch",
            headers=self.headers,
            json={"items": items}
        )
        return response.json()

# Usage
client = SHA224Client("your_api_key")

# Hash text
result = client.hash_text("Hello, World!")
print(f"Hash: {result['hash']}")

# Hash file
result = client.hash_file("document.pdf")
print(f"File hash: {result['hash']}")

# Batch processing
items = [
    {"id": "1", "data": "First text"},
    {"id": "2", "data": "Second text"}
]
results = client.batch_hash(items)
for item in results['results']:
    print(f"ID {item['id']}: {item['hash']}")

JavaScript/Node.js Example

JavaScript
const axios = require('axios');
const FormData = require('form-data');
const fs = require('fs');

class SHA224Client {
    constructor(apiKey) {
        this.apiKey = apiKey;
        this.baseURL = 'https://api.sha224.com/v2';
        this.headers = {
            'X-API-Key': apiKey,
            'Content-Type': 'application/json'
        };
    }

    async hashText(text) {
        try {
            const response = await axios.post(
                `${this.baseURL}/hash`,
                { data: text },
                { headers: this.headers }
            );
            return response.data;
        } catch (error) {
            console.error('Error:', error.response.data);
            throw error;
        }
    }

    async hashFile(filePath) {
        const form = new FormData();
        form.append('file', fs.createReadStream(filePath));

        try {
            const response = await axios.post(
                `${this.baseURL}/file`,
                form,
                {
                    headers: {
                        'X-API-Key': this.apiKey,
                        ...form.getHeaders()
                    }
                }
            );
            return response.data;
        } catch (error) {
            console.error('Error:', error.response.data);
            throw error;
        }
    }

    async verifyHash(data, hash) {
        try {
            const response = await axios.post(
                `${this.baseURL}/verify`,
                { data, hash },
                { headers: this.headers }
            );
            return response.data;
        } catch (error) {
            console.error('Error:', error.response.data);
            throw error;
        }
    }
}

// Usage
const client = new SHA224Client('your_api_key');

// Hash text
client.hashText('Hello, World!')
    .then(result => console.log('Hash:', result.hash));

// Verify hash
client.verifyHash('Hello, World!', '4149da18aa8bfc2b1e382c6c26556d01a92c261b6436dad5e3be3fcc')
    .then(result => console.log('Valid:', result.valid));
๐Ÿงช Try it Live

Response: