Beispiel #1
0
func main() {
	b := []byte("Test str")
	box, _ := enigma.New(time.Duration(1) * time.Minute)
	enc := box.Encrypt(b)
	fmt.Println(enc, len(enc))
	dec, e := box.Decrypt(enc)
	fmt.Println(string(dec), len(dec), e)

	b = []byte("Test str new Test str new")
	box, _ = enigma.New(time.Duration(1) * time.Minute)
	enc = box.Encrypt(b)
	fmt.Println(enc, len(enc))
	dec, e = box.Decrypt(enc)
	fmt.Println(string(dec), len(dec), e)

}
Beispiel #2
0
// New create cryptedcookie box
func New(maxAge int) (*TBoxCookie, error) {
	if maxAge < 10 {
		return nil, errors.New("maxAge must be > 10 seconds")
	}
	box, e := enigma.New(time.Duration(maxAge/2) * time.Second)
	if e != nil {
		return nil, e
	}
	return &TBoxCookie{
		box:    box,
		maxAge: maxAge,
	}, e
}