/pkce

Generate PKCE verify and challenge code

Primary LanguageGoMIT LicenseMIT

Proof Key for Code Exchange (PKCE)

Go GoDoc codecov

Generate PKCE verify and challenge code.

Usage

There are two ways of doing this

Your own string

You can put in your own string, example:

package main

import (
	"fmt"

	"github.com/akshaybabloo/pkce"
)

func main() {
	p := pkce.Pkce{
		RandomString: "45d7820e694481f399e7fb9c444f0cb63301a7254d1401443835d9af2c9a6a5ec5b243c3470feb945336025964ef05c8d2f0e44baf76762ba6136914",
	}

	fmt.Println(p.VerifyCode())  // This is optional
	// Output: 45d7820e694481f399e7fb9c444f0cb63301a7254d1401443835d9af2c9a6a5ec5b243c3470feb945336025964ef05c8d2f0e44baf76762ba6136914
	
	fmt.Println(p.ChallengeCode())
	// Output: iQoF8w9kq5RnuMdisRXypyOoMCF7FGz-ro7dwHjC28U
}

When you enter your own string, calling p.VerifyCode() is optional

Let us generate one for you

You can let the module generate a random string for you, but the length should be more than or equal to 43 and lest and or equal to 128.

package main

import (
	"fmt"

	"github.com/akshaybabloo/pkce"
)

func main() {
	p := pkce.Pkce{
		Length: 128,
	}

	fmt.Println(p.VerifyCode()) // This is optional
	// Output: 45d7820e694481f399e7fb9c444f0cb63301a7254d1401443835d9af2c9a6a5ec5b243c3470feb945336025964ef05c8d2f0e44baf76762ba6136914
	
	fmt.Println(p.ChallengeCode())
	// Output: iQoF8w9kq5RnuMdisRXypyOoMCF7FGz-ro7dwHjC28U
}

Note: Calling p.VerifyCode() optional, but calling it after p.ChallengeCode() will reset pkce.RandomString