clair/vendor/github.com/fernet/fernet-go/example_test.go

21 lines
370 B
Go
Raw Normal View History

2016-06-07 08:08:50 +00:00
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
}