Skip to content

The go-vtoken package is set of methods to generate and check tokens for users, emails, and other things without having to store tokens.

License

Notifications You must be signed in to change notification settings

waaldev/go-vtoken

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

github.com/siaminz/go-vtoken

Usage

Get the go-vtoken module

Note that you need to include the v in the version tag.

$ go get github.com/siaminz/[email protected]
package main

import (
    "fmt"
    "time"

    vtoken "github.com/siaminz/go-vtoken"
)

func main() {
    token, err := vtoken.New("[email protected]", time.Hour)
    if err != nil {
		panic(err)
	}
    fmt.Println(token)
    id, err := vtoken.Verify(token)
    if err != nil {
		panic(err)
	}
    fmt.Println(id.GetIdentifier())
}

Expiration

id.IsExpired()

Simple Token

Generate a token with custom length. this kind of tokens can't be verified.

package main

import (
    "fmt"
    "time"

    vtoken "github.com/siaminz/go-vtoken"
)

func main() {
    token := vtoken.GenerateSimpleToken(5)
    fmt.Println(token)
}

About

The go-vtoken package is set of methods to generate and check tokens for users, emails, and other things without having to store tokens.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages