{"uid":"cap_kz6RQ0SeAUKq0eKREpWtb","slug":"constant-time-string-comparison-bbb6213d","name":"Constant-Time String Comparison","description":"Compare two strings in constant time using node:crypto timingSafeEqual, preventing timing side-channel attacks. Returns whether the strings are equal and whether their lengths match. Different-length strings are always unequal but comparison does ...","url":"https://agent402.tools/api/constant-compare","method":"POST","headers":{},"bodySchema":{"type":"object","properties":{"a":{"type":"string","description":"First string to compare"},"b":{"type":"string","description":"Second string to compare"}}},"responseSchema":{"type":"json","example":{"equal":false,"lengthMatch":false}},"example":null,"exampleRequest":null,"tags":["x402"],"displayCostAmount":"0.001","displayCostAsset":"USDC","priceDynamic":false,"priceHint":null,"priceStatus":"priced","priceSource":"probe","requiresHandshake":false,"reviewCount":0,"rating":{"score":"0.00","successRate":"0.00","reviews":0,"stars":null,"state":"unrated"},"availabilityStatus":"unknown","priceObserved":null,"sessionDeposit":null,"pricing":{"kind":"static","summary":"$0.001/call","primary":{"kind":"static","protocol":"x402","network":"base","amountUsd":"0.001","per":"call","confidence":"exact"},"accepted":[{"kind":"static","protocol":"x402","network":"base","amountUsd":"0.001","per":"call","confidence":"exact"}]},"paymentMethods":[{"uid":"pm_7gm2hTBZQ1NWk68bn_BAZ","protocol":"x402","methodType":"crypto","chain":"base","mode":"charge","costAmount":"0.001","costPer":"request","priority":0,"asset":"0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913","unit":"request","depositMicros":null,"planRef":null}],"brandName":null,"brandSlug":null,"brandBaseUrl":null,"brandDocsUrl":null,"whatItDoes":"Compares two strings in constant time using cryptographic timing-safe equality to prevent timing side-channel attacks, returning equality status and length match.","exampleAgentPrompt":"Do a timing-safe constant-time comparison of these two strings to check if they're equal without leaking timing info: 'abc123secrettoken' and 'abc123secrettoken'.","exampleUseCases":null,"resultDescription":"Returns a JSON object indicating whether the two strings are equal (boolean) and whether their lengths match (boolean). Different-length strings are always reported as unequal, but the comparison still runs in constant time to avoid leaking length information.","failureModes":["Missing required field 'a' or 'b' results in a 400 error","Non-string inputs may cause schema validation errors","Network timeout on slow connections"],"whenToPreferThis":"Use this endpoint when you need to securely compare two strings — such as API keys, HMAC signatures, tokens, or passwords — in a way that prevents timing side-channel attacks. Prefer this over naive string equality checks whenever security is a concern and you cannot run server-side crypto locally.","instructions":null,"reviewSummary":null,"reviewSummaryHighlights":null,"reviewSummaryConcerns":null,"reviewSummaryGeneratedAt":null,"activationCount":0,"lastUsedAt":null,"lastSuccessfullyRanAt":null,"lastHealthCheckAt":"2026-09-14T19:14:04.382Z","isFirstParty":false}