# jwt - a simple JSON Web Token library written in Go

## Usage

```
package main

import (
	"fmt"
	"git.giftfish.de/ston1th/jwt"
	"log"
	"time"
)

func main() {
	// create a new signing instance
	JWT, err := jwt.New(time.Hour, jwt.NewMemBlacklist(), nil)
	if err != nil {
		log.Fatal(err)
	}

	// create a new token
	t := jwt.NewToken(jwt.Claims{
		"username": "admin",
	}, nil)

	// sign the token
	err = JWT.Sign(t)
	if err != nil {
		log.Fatal(err)
	}

	// print the token string
	token := t.String()
	fmt.Println(token)

	// decode the token string
	newToken, err := jwt.DecodeToken(token)
	if err != nil {
		log.Fatal(err)
	}

	// verify the decoded token
	err = JWT.Verify(newToken)
	if err != nil {
		log.Fatal(err)
	}

	// add the token to the blacklist
	err = JWT.Invalidate(newToken)
	if err != nil {
		log.Fatal(err)
	}

	// try to verify the blacklisted token, it should fail
	err = JWT.Verify(newToken)
	if err != nil {
		log.Fatal(err)
	}
}
```
