File: example_test.go

package info (click to toggle)
golang-github-fernet-fernet-go 0.0~git20180830.9eac43b-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 112 kB
  • sloc: makefile: 8
file content (20 lines) | stat: -rw-r--r-- 370 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
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
}