Eksempler
Create a token with an expiry
Du skriver inn
- Payload
- {"sub":"1234567890","name":"Example user"}
- Hemmelighet
- demo-only-key-demo-only-key-1234
- Utløp i sekunder
- 3600
- Klokke i sekunder
- 1700000000
Du får
- Token
- eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkV4YW1wbGUgdXNlciIsImV4cCI6MTcwMDAwMzYwMH0.UySYARwrOTgTlxbCPdSbh2yHYUnlQAHWW3hSs1Ss1lo
- Payload nå
- Subjekt: 1234567890; Navn: Example user; Utløper: 1700003600
The header is always alg HS256 and typ JWT. The tool adds exp as the clock plus 3600. This run used a fixed test clock, while the page uses the real time, so your exp and signature will differ. The secret is a throwaway demo value.
Kjørt med verktøyets egen kode.
Verify at two different times
Du skriver inn
- Token
- the token above
- Hemmelighet
- demo-only-key-demo-only-key-1234
- Klokke i sekunder
- 1700000100; 1700003600
Du får
- Signatur gyldig
- ja
- Tidsstatus
- within-time-window; expired
The signature matches in both cases. A token counts as expired once the clock reaches the exp value, so the second check, made exactly at 1700003600, reports expired.
Kjørt med verktøyets egen kode.
The wrong secret
Du skriver inn
- Token
- the token above
- Hemmelighet
- another-demo-key-another-demo-key-12
Du får
- Resultat
- JWT signature is invalid for this secret.
The signature is recomputed from the first two parts with the secret you give. A different secret gives a different signature, so the check fails, and the page shows its invalid-signature message.
Kjørt med verktøyets egen kode.
A secret that is too short
Du skriver inn
- Payload
- {"sub":"1"}
- Hemmelighet
- short
Du får
- Resultat
- HS256 requires a secret of at least 32 UTF-8 bytes.
The tool refuses any secret under 32 bytes before it signs anything, and the page then shows its general check-the-inputs message.
Kjørt med verktøyets egen kode.