encryp

package
v0.0.0-...-de89868 Latest Latest
Warning

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

Go to latest
Published: Jun 26, 2023 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package encryp - middleware, работает с шифрованием cookie аутентификации.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotFound            = errors.New("not found")
	ErrAlreadyExists       = errors.New("already exists")
	ErrBadRequest          = errors.New("bad request")
	ErrAccessDenied        = errors.New(`access denied`)
	ErrEncryptToken        = errors.New(`bad encryption keys`)
	ErrNewCipherNotCreated = errors.New(`NewCipher not created`)
	ErrNewGCMNotCreated    = errors.New(`NewGCM not created`)
)

ErrNotFound ошибка в случаи отсутствия данных ErrAlreadyExists ошибка в случаи если данные уже существуют ErrBadRequest ошибка в случаи не корректного запроса ErrAccessDenied ошибка в случаи отстуствия права доступа ErrEncryptToken ошибка в случаи отстуствия ключа шифрования

Functions

func EncryptionCookie

func EncryptionCookie(cfg *config.Cookie) func(next http.Handler) http.Handler

EncryptionCookie Compress is a middleware that sets and encrypts authentication cookies.

Types

type Encrypt

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

Encrypt -.

func NewEncrypt

func NewEncrypt(cfg *config.Cookie) *Encrypt

NewEncrypt создаёт новый Encrypt, который будет обрабатывать кодированные ответы.

func (*Encrypt) DecryptToken

func (e *Encrypt) DecryptToken(data string, secretKey string) (string, error)

DecryptToken расшифровать токен data - данные для расшифровки secretKey - пароль/ключ для шифрования, ключ с помощью которого шифровались данные возвращает расшифрованную строку

func (*Encrypt) EncryptToken

func (e *Encrypt) EncryptToken(secretKey string) (string, error)

EncryptToken шифрование и подпись data - данные для кодирования secretKey - пароль/ключ для шифрования, из него создаётся ключ с помощью которого можно шифровать и расшифровать данные возвращает зашифрованную строку/токен

func (*Encrypt) Handler

func (e *Encrypt) Handler(next http.Handler) http.Handler

Handler returns a new middleware that will encode the response based on the current settings.

Jump to

Keyboard shortcuts

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