clair/vendor/github.com/fernet/fernet-go/example_test.go
2016-06-07 10:08:50 +02:00

21 lines
370 B
Go

package fernet_test
import (
"fmt"
"time"
"github.com/fernet/fernet-go"
)
func Example() {
k := fernet.MustDecodeKeys("cw_0x689RpI-jtRR7oE8h_eQsKImvJapLeSbXpwF4e4=")
tok, err := fernet.EncryptAndSign([]byte("hello"), k[0])
if err != nil {
panic(err)
}
msg := fernet.VerifyAndDecrypt(tok, 60*time.Second, k)
fmt.Println(string(msg))
// Output:
// hello
}