Skip to content

Golang module for generating access tokens similar to GitHub tokens

License

Notifications You must be signed in to change notification settings

svicknesh/accesstoken

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Golang module for generating access token in Github token format

This Golang module creates an access token in the format of prefix``separator``code``crc32 checksum as is being done by GitHub.

The generated token can be used for purposes aside access. You can distinguish tokens using their prefixes within your own applications.

The token can be verified to be untampered if the checksum matches the code. This is meant to verify a token is valid before any checks in the database is made.

Usage

const (
    prefix = "abc"
    randomBytesLen = 32
)

token, err:= accesstoken.Generate(prefix, accesstoken.Separator, accesstoken.RandomBytesLen)
if nil != err {
    return
}

if !accesstoken.IsChecksumOK(prefix, accesstoken.Separator, token) {
    return
}

fmt.Println("token is ok")

About

Golang module for generating access tokens similar to GitHub tokens

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages