Comparison

Identifiers and secrets are not the same thing

These all come out as a random-looking string, so they get used for each other’s jobs. The dividing line is whether the string is merely unique or must also be unguessable, and getting that the wrong way round is a security bug rather than a style choice.

6 related tools

Side by side

Identifiers and secrets are not the same thing
Must be uniqueMust be unguessableExpiresSafe in a URL
UUID v4YesNot guaranteedNoYes
GUIDYesNot guaranteedNoYes
API keyYesYesWhen revokedNo
TOTP codeNoYesEvery 30 secondsNo
JWTYesIt is signed, not secretAt its exp claimOnly if short-lived

The short answer

GUID is simply Microsoft’s name for a UUID, so the two tools produce the same thing. The one that catches people out is the JWT: it is signed, not encrypted, so anyone holding it can read every claim inside by decoding the middle section. Never put anything in a JWT payload that the bearer should not see.

In more detail

A JWT is signed, not secret

The middle section is Base64 of plain JSON and anybody holding the token can read every claim in it. The signature proves the token has not been altered; it does nothing to conceal the contents. Putting an email address, a role or an internal identifier in there is handing it to whoever holds the token, which includes anybody who obtains it.

Unique and unguessable are different requirements

A UUID v4 is unique with overwhelming probability and is not a secret - it is generated from randomness, but nothing about the format guarantees the generator was cryptographically secure. Using one as an access token means an identifier is doing a secret's job, which is how unlisted URLs turn out to be guessable.

Why a TOTP code expires so quickly

It is derived from a shared secret and the current time in thirty-second steps, so an intercepted code is useless almost immediately. The secret behind it is the thing worth protecting; it never changes, and anybody holding it can generate codes forever. That is why pasting a real secret into any website, including this one, is a bad idea.

Tools covered by this comparison

More comparisons