How to design secure API keys: entropy, prefixes, and secret scanning explained
A software engineering guide outlines best practices for API key design, emphasizing that security depends on the randomness of the key body, with at least 22 alphanumeric characters needed to achieve the recommended 128-bit entropy threshold. Distinctive prefixes — such as Stripe's sk_live_ or GitHub's ghp_ — serve three practical purposes: distinguishing environments, speeding up incident triage, and enabling automated secret scanning tools to detect and revoke leaked keys in public repositories. The guide explains why UUIDs, despite meeting entropy requirements, are a poor choice because their generic format makes them invisible to secret-scanning tools. On the storage side, developers are advised to hash keys server-side using SHA-256, display the plaintext only once at issuance, and store only a short display suffix for user identification. The guide also stresses the importance of tracking key usage and building a rotation workflow — issue new, allow a dual-acceptance window, then revoke the old key — before it is ever needed.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.

Discussion (0)
Log in to join the discussion and vote.
Log in