encryptcookie

package
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: Sep 16, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ConfigDefault = Config{
	Next:      nil,
	Except:    []string{},
	Key:       "",
	Encryptor: EncryptCookie,
	Decryptor: DecryptCookie,
}

ConfigDefault 默认配置

Functions

func DecryptCookie

func DecryptCookie(value, key string) (string, error)

DecryptCookie 解密 Cookie 值

func EncryptCookie

func EncryptCookie(value, key string) (string, error)

EncryptCookie 加密 Cookie 值

func GenerateKey

func GenerateKey() string

GenerateKey 生成加密密钥

func New

func New(config ...Config) core.MiddlewareFunc

New 创建一个新的 encryptcookie 中间件

Types

type Config

type Config struct {
	Next      func(c *kanggo.Context) bool                      // 可选:跳过此中间件的函数
	Except    []string                                          // 可选:不需要加密的 Cookie 名称列表
	Key       string                                            // 必填:Base64 编码的唯一密钥,用于加密和解密 Cookie
	Encryptor func(decryptedString, key string) (string, error) // 可选:自定义加密函数
	Decryptor func(encryptedString, key string) (string, error) // 可选:自定义解密函数
}

Config 是 encryptcookie 中间件的配置结构体

Jump to

Keyboard shortcuts

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