Esempio n. 1
0
File: main.go Progetto: Cergoo/gol
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)

}
Esempio n. 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
}