func (c *CookieOverseer) encode(plaintext string) (string, error) {
	nonce := make([]byte, c.gcmBlockMode.NonceSize())
	if _, err := rand.Read(nonce); err != nil {
		return "", errors.Wrap(err, "failed to encode session cookie value")
	}
	ciphertext := c.gcmBlockMode.Seal(nonce, nonce, []byte(plaintext), nil)
	return base64.StdEncoding.EncodeToString(ciphertext), nil
}
encode into base64'd aes-gcm
package abcsessions
import (
	"crypto/aes"
	"crypto/cipher"
	"crypto/rand"
	"encoding/base64"
	"net/http"
	"github.com/friendsofgo/errors"
)
type CookieOverseer struct {
	options CookieOptions
	secretKey    []byte
	gcmBlockMode cipher.AEAD
	resetExpiryMiddleware
}
func NewCookieOverseer(opts CookieOptions, secretKey []byte) *CookieOverseer {
	if len(opts.Name) == 0 {
		panic("cookie name must be provided")
	}
	block, err := aes.NewCipher(secretKey)
	if err != nil {
		panic(err)
	}
	gcm, err := cipher.NewGCM(block)
	if err != nil {
		panic(err)
	}
	o := &CookieOverseer{
		options:      opts,
		secretKey:    secretKey,
		gcmBlockMode: gcm,
	}
	o.resetExpiryMiddleware.resetter = o
	return o
}
func (c *CookieOverseer) Get(w http.ResponseWriter, r *http.Request) (string, error) {
	val, err := c.options.getCookieValue(w, r)
	if err != nil {
		return "", errors.Wrap(err, "unable to get session value from cookie")
	}
	return c.decode(val)
}
func (c *CookieOverseer) Set(w http.ResponseWriter, r *http.Request, value string) error {
	ev, err := c.encode(value)
	if err != nil {
		return errors.Wrap(err, "unable to encode session value into cookie")
	}
	w.(cookieWriter).SetCookie(c.options.makeCookie(ev))
	return nil
}
func (c *CookieOverseer) Del(w http.ResponseWriter, r *http.Request) error {
	c.options.deleteCookie(w)
	return nil
}
func (c *CookieOverseer) Regenerate(w http.ResponseWriter, r *http.Request) error {
	panic("cookie sessions do not use session ids")
}
func (c *CookieOverseer) SessionID(w http.ResponseWriter, r *http.Request) (string, error) {
	panic("cookie sessions do not use session ids")
}
func (c *CookieOverseer) ResetExpiry(w http.ResponseWriter, r *http.Request) error {
	if c.options.MaxAge == 0 {
		return nil
	}
	val, err := c.options.getCookieValue(w, r)
	if err != nil {
		return errors.Wrap(err, "unable to get session value from cookie")
	}
	w.(cookieWriter).SetCookie(c.options.makeCookie(val))
	return nil
}