gosecurecookies

package module
v1.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 26, 2023 License: MIT Imports: 10 Imported by: 1

README

go-secure-cookies

A secure cookie module for golang


// securekey must be at least 16 char long
// The key argument should be the AES key,
// either 16, 24, or 32 bytes to select
// AES-128, AES-192, or AES-256.
var key = "dsdfs6dfs61dssdfsdfdsdsfsdsdllsd"
cookies, err := NewCookies(key)

var ck http.Cookie
ck.Name = "test1"
ck.Value = "this-is-a-test-and-more"

//write----
w  http.ResponseWriter
err := cookies.write(w, ck)


var name = "test1"

//read----
r    *http.Request
cookieValue, err := cookies.Read(r, name)


Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cookies

type Cookies interface {
	Write(w http.ResponseWriter, cookie http.Cookie) error
	Read(r *http.Request, name string) (string, error)
}

Cookies Cookies

func NewCookies

func NewCookies(secureKey string) (Cookies, error)

NewCookies NewCookies

type Encrypt

type Encrypt interface {
	Encrypt(s string) (string, error)
	Decrypt(es string) (string, error)
}

Encrypt Encrypt

func NewEncrypt

func NewEncrypt(secretKey string) (Encrypt, error)

NewEncrypt NewEncrypt

type GCMEncrypt

type GCMEncrypt struct {
	// contains filtered or unexported fields
}

GCMEncrypt GCMEncryption

func (*GCMEncrypt) Decrypt

func (e *GCMEncrypt) Decrypt(es string) (string, error)

Decrypt Decrypt

func (*GCMEncrypt) Encrypt

func (e *GCMEncrypt) Encrypt(s string) (string, error)

Encrypt Encrypt

type SecureCookies

type SecureCookies struct {
	// contains filtered or unexported fields
}

SecureCookies SecureCookies

func (*SecureCookies) Read

func (s *SecureCookies) Read(r *http.Request, name string) (string, error)

func (*SecureCookies) Write

func (s *SecureCookies) Write(w http.ResponseWriter, cookie http.Cookie) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL