Need to verify data integrity or detect transmission errors? This guide covers everything you need to know about calculating checksums programmatically via API, including CRC32, Adler32, use cases, and implementation examples in multiple languages.
What is a Checksum?
A checksum is a small-sized value derived from a block of data used to detect errors during transmission or storage. Unlike cryptographic hashes, checksums are optimized for speed and error detection rather than security.
For example, the CRC32 checksum of "Hello World" is 4a17b156.
Checksum Types
Different checksum algorithms serve different purposes:
CRC32 (Recommended)
Cyclic Redundancy Check with 32-bit output. Used in ZIP files, PNG images, Ethernet, and many network protocols. Excellent at detecting common transmission errors.
Adler32
Faster than CRC32 but with slightly weaker error detection. Used in zlib compression. Good for applications where speed is critical.
CRC16
16-bit variant used in older protocols and embedded systems. Smaller output but weaker error detection than CRC32.
Using the Checksum API
TinyFn provides a simple endpoint to calculate checksums:
POST https://api.tinyfn.io/v1/crypto/checksum
Headers: X-API-Key: your-api-key
Content-Type: application/json
{
"data": "Hello World",
"algorithm": "crc32"
}
{
"checksum": "4a17b156",
"algorithm": "crc32",
"decimal": 1243066710
}
Parameters
| Parameter | Type | Description |
|---|---|---|
data |
string | The data to checksum |
algorithm |
string | Algorithm: crc32, adler32, crc16, crc32c (default: crc32) |
encoding |
string | Input encoding: utf8, base64, hex (default: utf8) |
Code Examples
JavaScript / Node.js
// Calculate CRC32 checksum
const response = await fetch(
'https://api.tinyfn.io/v1/crypto/checksum',
{
method: 'POST',
headers: {
'X-API-Key': 'your-api-key',
'Content-Type': 'application/json'
},
body: JSON.stringify({
data: 'Hello World',
algorithm: 'crc32'
})
}
);
const { checksum, decimal } = await response.json();
console.log(`Hex: ${checksum}`); // 4a17b156
console.log(`Decimal: ${decimal}`); // 1243066710
Python
import requests
response = requests.post(
'https://api.tinyfn.io/v1/crypto/checksum',
json={
'data': 'Hello World',
'algorithm': 'crc32'
},
headers={'X-API-Key': 'your-api-key'}
)
data = response.json()
print(f"Hex: {data['checksum']}") # 4a17b156
print(f"Decimal: {data['decimal']}") # 1243066710
cURL
curl -X POST "https://api.tinyfn.io/v1/crypto/checksum" \
-H "X-API-Key: your-api-key" \
-H "Content-Type: application/json" \
-d '{
"data": "Hello World",
"algorithm": "crc32"
}'
Common Use Cases
- File Downloads: Verify downloaded files match the original
- Data Transfer: Detect corruption during network transmission
- Backup Verification: Ensure backups are not corrupted
- Database Records: Quick comparison of record contents
- Caching: Generate cache keys from content
Best Practices
- Use CRC32 for reliability: Better error detection than Adler32
- Don't use for security: Checksums are not cryptographically secure
- Store with data: Keep checksums alongside files for verification
- Consider CRC32C: Hardware-accelerated on modern CPUs for better performance
Use via MCP
Your AI agent can call this tool directly via Model Context Protocol — no HTTP code needed. Add TinyFn to Claude Desktop, Cursor, or any MCP client:
{
"mcpServers": {
"tinyfn-crypto": {
"url": "https://api.tinyfn.io/mcp/crypto/",
"headers": {
"X-API-Key": "your-api-key"
}
}
}
}
See all cryptography tools available via MCP in our Cryptography MCP Tools for AI Agents guide.
Try the Checksum API
Get your free API key and start calculating checksums in seconds.
Get Free API Key