Coder Social home page Coder Social logo

pkce's Introduction

Proof Key for Code Exchange (PKCE)

Go GoDoc codecov

Generate PKCE verify and challenge code.

Instillation

go get github.com/akshaybabloo/pkce/v2

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/v2"
)

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/v2"
)

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

pkce's People

Contributors

akshaybabloo avatar dependabot[bot] avatar lgtm-migrator avatar

Watchers

 avatar  avatar  avatar

pkce's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.