Skip to main content

pyreqsign

HMAC-based API request signing with environment-bound key derivation for microservices.

Installation

pip install pyreqsign

Quick Start

from pyreqsign import derive_key, sign, verify, sign_request

# Derive a machine-bound signing key from your secret
key = derive_key("my-api-key")

# Sign a canonical message
signature = sign(key, b"POST\n/users\n1714300000\n")
# → base64url signature string

# Verify on the server side
is_valid = verify(key, b"POST\n/users\n1714300000\n", signature)

# Or sign headers via sign_request — the returned headers include a
# single-use nonce (X-EnvSign-Nonce) that is bound into the signature and
# consumed by the server on first use, so replayed requests are rejected.
# Attach every returned header to your HTTP call (the json_body you pass
# is bound into the signature so a server can detect tampering; you send
# the body yourself).
headers = sign_request("my-api-key", "POST", "https://api.example.com/v1/data",
                       json_body={"action": "update"})
# → {"Authorization": "EnvSign ES-v2:...", "X-EnvSign-Timestamp": "1714300000",
#    "X-EnvSign-Nonce": "9f2a...", ...}
#   then: requests.post(url, json={"action": "update"}, headers=headers)

Why EnvSign?

Standard HMAC signing only binds the secret key. EnvSign additionally binds the signing environment — the derived key depends on both the secret AND the machine fingerprint, making it ideal for:

  • Microservice-to-microservice auth where each service instance has a unique identity
  • API gateway request validation with one-time (nonce) replay protection — every signed request carries a fresh X-EnvSign-Nonce that is bound into the signature and consumed by the server on first use
  • Webhook verification where the sender environment is part of the trust chain

API

Core Signing

All cryptographic operations are implemented in the native extension pyreqsign._native; the Python layer is a thin re-export.

Function Description
derive_key(secret) Derive a 256-bit machine-bound signing key (sha256(md5(hostname)+secret))
sign(key, message, ...) Sign a message, returns base64url signature string
verify(key, message, sig) Verify signature (constant-time comparison)
sign_request(secret, method, url, json_body=None) Sign a full HTTP request, returns auth headers; json_body is canonicalized, hashed and bound into the signature (not sent by itself)
es_hmac(key, message, ...) Low-level ES-HMAC primitive
generate_key_id(api_key) Generate a machine-bound key identifier

License

MIT

Metadata

Release files for pyreqsign 1.3.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distributions (wheels)

Table of built distributions (wheels) for pyreqsign 1.3.5
File
pyreqsign-1.3.5-cp38-abi3-win_amd64.whl CPython 3.8 abi3 Windows x86-64 Details
pyreqsign-1.3.5-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.8 abi3 Linux glibc 2.17+ x86-64 Details
pyreqsign-1.3.5-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl CPython 3.8 abi3 Linux glibc 2.17+ ARM64 Details
pyreqsign-1.3.5-cp38-abi3-macosx_11_0_arm64.whl CPython 3.8 abi3 macOS 11.0+ ARM64 Details

Total release size: 3.2 MB

Release files / pyreqsign-1.3.5-cp38-abi3-win_amd64.whl

Download URL pyreqsign-1.3.5-cp38-abi3-win_amd64.whl
Size 757.1 kB
Tags CPython 3.8 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
19e1361dea71f399f83c78f34e6a98afaa74ad3b2695f2ef171cd07198ffc0ff
BLAKE2b-256 checksum
How to use checksums
8b5829dbeda8f7e92e424787cdd9ecdfda8bc4b828bedf354ee81e8e06f7471d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.5

Release files / pyreqsign-1.3.5-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL pyreqsign-1.3.5-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 864.4 kB
Tags CPython 3.8 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
3634dd3a3b58ad4d451157e875a6a81973e0118a474c517ea4c74306125bd2d2
BLAKE2b-256 checksum
How to use checksums
de40fab630d50790d956d4bed60b7b8c19a2cc48790108ceb66592d4ed8fc58e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.5

Release files / pyreqsign-1.3.5-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl

Download URL pyreqsign-1.3.5-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Size 819.0 kB
Tags CPython 3.8 Linux glibc 2.17+ ARM64 abi3
SHA-256 checksum
How to use checksums
ca3d626c9aa9accf82e55ad89585dbdfa127a7dda7e15e07398fac30abfe1cd3
BLAKE2b-256 checksum
How to use checksums
379f9c09ec26b3b2a142c3d99e8b0b093b503e5402a186a23a4f6ea7d7237e13
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.5

Release files / pyreqsign-1.3.5-cp38-abi3-macosx_11_0_arm64.whl

Download URL pyreqsign-1.3.5-cp38-abi3-macosx_11_0_arm64.whl
Size 736.1 kB
Tags CPython 3.8 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
82c7113fc497ad5bc15fc81b7a6c260224a76d825e2e5d2ce79719ae02d0cf62
BLAKE2b-256 checksum
How to use checksums
5f4646793e795360f8d68bf0d82fc97810b309108ea59b3a5bb80c34eb2a40d1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.5

Security for pyreqsign 1.3.5

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page