cookiecloud

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: May 8, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BytesToKey

func BytesToKey(salt, data []byte, h hash.Hash, keyLen, blockLen int) (key, iv []byte, err error)

BytesToKey From https://github.com/walkert/go-evp . BytesToKey implements the Openssl EVP_BytesToKey logic. It takes the salt, data, a hash type and the key/block length used by that type. As such it differs considerably from the openssl method in C.

func BytesToKeyAES256CBC

func BytesToKeyAES256CBC(salt, data []byte) (key []byte, iv []byte, err error)

BytesToKeyAES256CBC implements the SHA256 version of EVP_BytesToKey using AES CBC

func BytesToKeyAES256CBCMD5

func BytesToKeyAES256CBCMD5(salt, data []byte) (key []byte, iv []byte, err error)

BytesToKeyAES256CBCMD5 implements the MD5 version of EVP_BytesToKey using AES CBC

func Decrypt

func Decrypt(password string, ciphertext string) ([]byte, error)

Decrypt a CryptoJS.AES.encrypt(msg, password) encrypted msg. ciphertext is the result of CryptoJS.AES.encrypt(), which is the base64 string of "Salted__" + [8 bytes random salt] + [actual ciphertext]. actual ciphertext is padded (make it's length align with block length) using Pkcs7. CryptoJS use a OpenSSL-compatible EVP_BytesToKey to derive (key,iv) from (password,salt), using md5 as hash type and 32 / 16 as length of key / block. See: https://stackoverflow.com/questions/35472396/how-does-cryptojs-get-an-iv-when-none-is-specified , https://stackoverflow.com/questions/64797987/what-is-the-default-aes-config-in-crypto-js

func Encrypt

func Encrypt(password string, plaintext string) (string, error)

Encrypt encrypts the plaintext using the password.

func Md5String

func Md5String(inputs ...string) string

Md5String return the MD5 hex hash string (lower-case) of input string(s)

Types

type Body

type Body struct {
	Uuid      string `json:"uuid"`
	Encrypted string `json:"encrypted"`
}

type Client

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

func NewClient

func NewClient(cfg *Config) (*Client, error)

func (*Client) Close

func (c *Client) Close()

func (*Client) Get

func (c *Client) Get(ctx context.Context, req *GetReq) (*GetResp, error)

Get sends a request to the server to get the cookie. see: https://github.com/easychen/CookieCloud/blob/master/api/app.js#L46

func (*Client) Push

func (c *Client) Push(ctx context.Context, req *PushReq) (*PushResp, error)

Push sends a request to the server to update the cookie. see: https://github.com/easychen/CookieCloud/blob/master/api/app.js#L28

func (*Client) SetHeaders

func (c *Client) SetHeaders(headers map[string]string)

type Config

type Config struct {
	ApiUrl  string        `json:"api_url" yaml:"apiUrl"`
	Timeout time.Duration `json:"timeout" yaml:"timeout"`
	Retry   int           `json:"retry" yaml:"retry"`
	Debug   bool          `json:"debug" yaml:"debug"`
}
type Cookie struct {
	CookieData       map[string][]CookieData      `json:"cookie_data"`
	LocalStorageData map[string]map[string]string `json:"local_storage_data"`
	UpdateTime       time.Time                    `json:"update_time"`
}

type CookieData

type CookieData struct {
	Domain         string  `json:"domain"`
	ExpirationDate float64 `json:"expirationDate"`
	HostOnly       bool    `json:"hostOnly"`
	HttpOnly       bool    `json:"httpOnly"`
	Name           string  `json:"name"`
	Path           string  `json:"path"`
	SameSite       string  `json:"sameSite"`
	Secure         bool    `json:"secure"`
	Session        bool    `json:"session"`
	StoreId        string  `json:"storeId"`
	Value          string  `json:"value"`
}

func (CookieData) GetExpired

func (c CookieData) GetExpired() time.Time

type GetReq

type GetReq struct {
	Uuid            string `json:"-"`
	Password        string `json:"password"`
	CloudDecryption bool   `json:"-"` // 如果指定了ture则在服务端解密并返回,为了安全不建议这么使用。
}

type GetResp

type GetResp struct {
	Body
	Cookie
}

type PushReq

type PushReq struct {
	Uuid     string `json:"uuid"`
	Password string `json:"password"`
	Cookie
}

type PushResp

type PushResp struct {
	Action string `json:"action"` // done error
}

Jump to

Keyboard shortcuts

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