sec-hash-sha256 Edge Function — Security
SecurityHashes a string using SHA-256 via the Web Crypto API. Supports hex and base64 output. Zero dependencies.
Edge function sec-hash-sha256 Hashes a string using SHA-256 via the Web Crypto API. Supports hex and base64 output. Zero dependencies.. Deployed on Cloudflare Workers — zero cold starts, globally distributed. Mount it via your Aerostack workspace to call it from any AI agent.
npx aerostack add navin/sec-hash-sha256 Use with AI Assistants
MCPConnect Claude, Cursor, or any MCP-compatible client — then call this function by slug
① Add MCP Server
Add this once — access all Aerostack functions from your AI tool.
{
"mcpServers": {
"aerostack": {
"url": "https://mcp.aerostack.dev",
"type": "http"
}
}
} ② Call this function
Ask your AI to use the call_function tool with this slug:
call_function({
slug: "sec-hash-sha256",
args: {
"input": "example_input",
"format": "example_format"
}
}) sec-hash-sha256
Hashes a string using SHA-256 via the Web Crypto API. Supports hex and base64 output. Includes a constant-time verify function. Zero external dependencies.
Install
aerostack function add sec-hash-sha256
Usage
import { hashSha256, verifySha256 } from './functions/sec-hash-sha256';
// Hash a string (hex)
const hash = await hashSha256('my-secret');
// → '4a8a0...'
// Hash as base64
const b64 = await hashSha256('my-secret', 'base64');
// Verify (constant-time)
const valid = await verifySha256('my-secret', hash); // true
API
POST /api/sec-hash-sha256
{ "input": "my string", "format": "hex" }
{ "success": true, "data": { "hash": "2cf24d...", "format": "hex" } }
POST /api/sec-hash-sha256/verify
{ "input": "my string", "hash": "2cf24d...", "format": "hex" }
{ "success": true, "data": { "valid": true } }
| Field | Type | Required | Default |
|---|---|---|---|
input |
string | ✅ | — |
format |
"hex" | "base64" |
❌ | "hex" |
Metadata
Tags
Publisher
@navin verified
Build and publish your own functions
Write a TypeScript function, deploy it to the edge, and share it with thousands of developers — in minutes.
More Security Functions
Browse Security Functions →sec-api-key-generate
by @navin
Generates a cryptographically random API key with a custom prefix using a base62 alphabet — no ambiguous characters, URL-safe.
sec-cors-validate
by @navin
Validates a request Origin against an allow list and returns the correct CORS response headers to set — supports wildcards and credentials.
sec-csp-generate
by @navin
Generates a Content-Security-Policy header value from a structured directives object — supports report-only mode and report-uri.
sec-decrypt-aes
by @navin
Decrypts an AES-256-GCM encrypted bundle produced by sec-encrypt-aes — key is derived via SHA-256, auth tag is verified automatically.
sec-encrypt-aes
by @navin
Encrypts a string with AES-256-GCM using Web Crypto — key is derived via SHA-256, output is a portable IV:ciphertext bundle.
sec-hmac-sign
by @navin
Signs a string payload with HMAC-SHA256 or HMAC-SHA512 using Web Crypto — outputs a hex-encoded signature.
Frequently asked questions
What does the sec-hash-sha256 function do? +
sec-hash-sha256 is a serverless edge function for security automation written in aerostack. Deploy it to Cloudflare Workers via your Aerostack workspace.
How do I deploy the sec-hash-sha256 function? +
Install the Aerostack CLI and run: ```bash aerostack deploy function @navin/sec-hash-sha256 ``` It will be live on Cloudflare Workers in seconds.
What runtime does sec-hash-sha256 use? +
sec-hash-sha256 runs on aerostack on the Cloudflare Workers edge runtime — zero cold starts, globally distributed.
Can I customise the sec-hash-sha256 function? +
Yes. Fork the function from your Aerostack dashboard, modify the source, and redeploy. All changes are version-controlled.