Skip to content

Latest commit

 

History

History
61 lines (45 loc) · 847 Bytes

README.md

File metadata and controls

61 lines (45 loc) · 847 Bytes

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)
}