Пример #1
0
func main() {
	http.HandleFunc("/", handleHome)
	http.HandleFunc("/login", handleLogin)
	http.HandleFunc("/logout", handleLogout)

	var err error
	tokener, err = securetoken.NewTokener(unsafeKey, 24*time.Hour)
	if err != nil {
		panic(err)
	}

	log.Println("Demo running at http://localhost:8080")
	log.Fatal(http.ListenAndServe(":8080", nil))
}
Пример #2
0
func Example() {
	key := []byte("1111111111111111")
	tok, err := securetoken.NewTokener(key, 1*time.Minute)
	if err != nil {
		panic(err)
	}
	sealed, err := tok.SealString("hello world")
	if err != nil {
		panic(err)
	}
	unsealed, err := tok.UnsealString(sealed)
	if err != nil {
		panic(err)
	}

	fmt.Println(unsealed)

	// Output:
	// hello world
}