yopass

package
v0.0.0-...-c5db528 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2024 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrEmptyKey = errors.New("empty encryption key")

ErrEmptyKey is returned when no encryption key is provided.

View Source
var ErrInvalidKey = errors.New("invalid decryption key")

ErrInvalidKey is returned when a given decryption key is invalid.

View Source
var ErrInvalidMessage = errors.New("invalid message")

ErrInvalidMessage is returned when a given message is invalid.

View Source
var HTTPClient = http.DefaultClient

HTTPClient allows modifying the underlying http.Client.

Functions

func Decrypt

func Decrypt(r io.Reader, key string) (content, filename string, err error)

Decrypt reads the provided ciphertext and returns the plaintext decrypted with the given key. The ciphertext format is specified by the yopass frontend, no assumptions about the format should be made.

func Encrypt

func Encrypt(r io.Reader, key string) (string, error)

Encrypt reads the provided plaintext and returns a ciphertext encrypted with the given key. No assumptions about the ciphertext format should be made, the encryption method might change in future versions.

func Fetch

func Fetch(server string, id string) (string, error)

Fetch retrieves a secret by its ID from the specified server.

func GenerateKey

func GenerateKey() (string, error)

GenerateKey creates a new encryption key from a cryptographically secure random number generator. The format matches the Javascript implementation.

func ParseURL

func ParseURL(s string) (id, key string, fileOpt, keyOpt bool, err error)

ParseURL returns secret ID and key from a regular yopass URL.

func SecretURL

func SecretURL(url, id, key string, fileOpt, manualKeyOpt bool) string

SecretURL returns a URL which decryts the specified secret in the browser.

func Store

func Store(server string, s Secret) (string, error)

Store sends the secret to the specified server and returns the secret ID.

Types

type Secret

type Secret struct {
	Expiration  int32  `json:"expiration,omitempty"`
	Message     string `json:"message"`
	OneTime     bool   `json:"one_time,omitempty"`
	AccessToken string `json:"access_token,omitempty"`
}

Secret holds the encrypted message

func (*Secret) ToJSON

func (s *Secret) ToJSON() ([]byte, error)

ToJSON converts a Secret to json

type ServerError

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

ServerError represents a yopass server error.

func (*ServerError) Error

func (e *ServerError) Error() string

func (*ServerError) Unwrap

func (e *ServerError) Unwrap() error

Jump to

Keyboard shortcuts

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