Toolvito

Works on this device

Pkce Generator

Make a code verifier and its code challenge for PKCE, the extra step that protects the OAuth authorization code flow of apps (RFC 7636). The verifier comes from the secure random generator of your browser, and the challenge is its SHA-256 in Base64url (S256). Nothing is sent or saved.

Make or check PKCE values

Makes a new random code verifier with the secure generator of your browser and works out its S256 code challenge.

Settings

32 bytes give a verifier of 43 characters with 256 bits. 96 bytes give the longest one, 128 characters.

Values are made in this browser. They are not sent or saved.

Your verifier and challenge will show here

Choose Generate to make a pair.

How to use the PKCE generator

  1. Choose Make a code verifier and its code challenge and choose Generate. The default makes 32 random bytes, written as a verifier of 43 characters.
  2. Put the code challenge and code_challenge_method=S256 into the authorization request (the address of the sign-in page).
  3. Keep the code verifier in your app. Send it only with the token request, when the app swaps the authorization code for tokens.
  4. To check a verifier you already have, choose Work out the code challenge from a code verifier and paste it. Paste the challenge that was sent too, to see whether they fit.

How the verifier and the challenge are made

code_verifier: 43 to 128 characters from A to Z, a to z, 0 to 9 and the four signs - . _ ~ (RFC 7636, section 4.1). RFC 7636 suggests 32 random bytes written in Base64url, which gives 43 characters and 256 bits of randomness. This tool can also pick each character on its own from the 66 allowed ones: then a verifier of n characters holds n × log2(66), about 6.04 bits per character.

code_challenge = BASE64URL(SHA-256(code_verifier)) with code_challenge_method=S256 (section 4.2). Base64url is Base64 with - and _ in place of + and /, and without = padding, so a challenge always has 43 characters.

Random bytes come from the secure random generator of your browser (Web Crypto). Characters are picked without bias: values that would favour some characters are thrown away and drawn again. If your browser has no secure generator, the tool stops and says so.

Why only S256

RFC 7636 also names the method plain, where the challenge is the verifier itself. Anyone who sees the sign-in address would then see the secret. A client should use plain only when it cannot work out SHA-256 at all (section 4.2), and every current browser and phone can. So this tool makes S256 challenges only.

Keep the verifier secret

  • The code verifier proves that the app which asks for the token is the one that started the sign-in. Keep it in the app, and never put it into the sign-in address.
  • Make a new verifier for every sign-in. A verifier that is used twice gives no protection.
  • This page does not send or save the verifier, and it has no save option and no CSV file. The verifier you paste in the second mode is masked, and the result does not show it.

Worked example

RFC 7636 appendix B starts from 32 random bytes (116, 24, 223, ...). Written in Base64url they are the verifier dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk. Its SHA-256 in Base64url is the challenge E9Melhoa2OwvFrEMTJguCHaoeK1t8URWbuGJSstw-cM.

Choose Try an example in the second mode to see the same challenge worked out in your browser.

Limits you should know

  • The tool makes and checks the values only. It does not send an authorization or token request, and it cannot tell whether a server supports PKCE.
  • The method plain is not offered.
  • For a sign-in in a real app, let the app make the verifier itself at the moment of each sign-in. Use this page for tests, examples and checks.

Related tools