Skip to main content
Uttir
By Uttir 3 min read

How to Sign and Verify API Requests With HMAC, RSA, and JWT

Generate HMAC signatures, create 2048–4096-bit RSA keypairs, sign and verify SHA256withRSA payloads, build SNAP strings, and sign JWTs locally.

API authentication uses symmetric HMACs when both sides share a secret, asymmetric RSA signatures when partners verify with a public key, and JWTs for portable signed claims. Generate keys, build SNAP canonical strings, sign HS256/RS256 tokens, verify RSA signatures, and identify unknown digests directly in your browser.

Debugging signed webhooks, payment gateway callbacks, or JWT auth headers almost always fails for boring reasons: an extra space in the JSON body, a PKCS#1 vs. PKCS#8 PEM mismatch, or an unverified signature algorithm. Pasting production secrets or private keys into random web tools to check those headers is an avoidable security risk.

All seven cryptographic signing and verification utilities on Uttir run locally inside your browser tab via JavaScript and Web Crypto, with zero network transmission.

1. Symmetric signing with HMAC

When both the sender and receiver hold the same shared secret—common for webhook signatures (Stripe, GitHub, Slack) and internal service-to-service headers—use an HMAC rather than a plain hash. A plain SHA-256 hash only checks integrity; an HMAC proves possession of the secret key.

The HMAC Generator computes keyed-hash authentication codes locally across supported SHA algorithms from your message and secret, and lets you copy the resulting MAC or generate a shareable test link when working with dummy values.

2. Asymmetric RSA keypairs, signing, and verification

When external partners need to verify requests without holding your signing secret, asymmetric RSA signatures separate the private signing key from the public verification key:

  1. Generate a test or staging keypair in RSA Keygen (2048-bit standard, 3072-bit strong, or 4096-bit) and download private and public PEM files directly from Web Crypto.
  2. Sign a canonical string in RSA Sign using either a PKCS#1 or PKCS#8 private PEM (PKCS#1 keys are converted automatically) to produce a Base64 SHA256withRSA (X-SIGNATURE) string.
  3. Verify a signature in RSA Verify using the public PEM, the exact signed message, and either SHA256withRSA (PKCS#1 v1.5) or RSASSA-PSS padding.

A signature check fails if even a single whitespace byte or line ending differs between the signed string and the verified string.

3. Build BI-SNAP canonical strings without whitespace bugs

Open-banking and payment specifications such as BI-SNAP require strict canonicalization before signing with RSA. Any stray space in a JSON payload changes its SHA-256 body hash and triggers an invalid-signature error from the gateway.

The SNAP String to Sign tool supports both BI-SNAP request modes locally:

  • B2B access token — builds clientID | timestamp and signs with your private key.
  • Transactional requests — minifies your JSON request body, computes its lowercase hex SHA-256 digest, builds METHOD : relativePath : bodyHash : timestamp, outputs the exact minified body bytes to send over the wire, and signs the full stringToSign into X-SIGNATURE.

4. Sign HS256 and RS256 JWTs for local testing

When testing middleware or reproducing an expired/custom claim locally, the JWT Sign tool builds and signs JSON Web Tokens in the browser using either a symmetric HMAC secret (HS256) or an RSA private PEM key (RS256). Pair it with JWT Decoder to inspect claims and expiration timestamps side by side.

5. Identify unknown digests in logs or headers

If an integration log drops an unfamiliar checksum or signature digest without naming the algorithm, paste it into Hash Identifier. It classifies hex vs. Base64 encoding, lists candidate algorithms matching the digest length, and lets you hash a suspected plaintext input across standard algorithms to confirm an exact match locally.

Choosing the right signing mechanism

Use caseMechanismTools
Webhook or shared-secret APISymmetric HMAC-SHA256HMAC Generator
Partner API / non-repudiationAsymmetric RSA (PKCS#1 v1.5 / PSS)RSA Keygen, RSA Sign, RSA Verify
BI-SNAP payment requestsCanonicalized RSA-SHA256SNAP String to Sign
Stateless auth bearer tokensSigned JWT (HS256 / RS256)JWT Sign

Further reading

Primary specifications: RFC 2104 — HMAC, RFC 7519 — JSON Web Token (JWT), RFC 8017 — PKCS #1 RSA Cryptography, and MDN — SubtleCrypto Web Crypto API.

Frequently asked questions

Why does a valid RSA signature fail verification when my JSON payload looks identical?
Most transactional signing specs hash the exact request body bytes. Extra indentation, trailing newlines, or reordered keys change the SHA-256 body hash—use the exact minified body string generated by SNAP String to Sign.
When should I choose HS256 vs. RS256 for signing JWTs?
Use HS256 when the same trusted backend both issues and verifies tokens using a shared secret. Use RS256 when external services or clients need to verify tokens with a public key without having permission to mint new tokens.
Can RSA Sign accept both PKCS#1 and PKCS#8 private keys?
Yes. RSA Sign detects the PEM header automatically and converts PKCS#1 private keys in your browser before signing via Web Crypto.
#security#cryptography#api#jwt#rsa#hmac

New tools and guides, once a week

One short email when something new ships. Your address is kept on our own server and used for nothing else.