crypto

package
v2.6.1 Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2026 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterEncryptor

func RegisterEncryptor(encryptor Encryptor)

RegisterEncryptor registers an encryptor. It panics when the encryptor is nil or has an empty name, and overwrites the encryptor registered under the same name.

func RegisterSigner

func RegisterSigner(signer Signer)

RegisterSigner registers a signer. It panics when the signer is nil or has an empty name, and overwrites the signer registered under the same name.

Types

type Encryptor

type Encryptor interface {
	// Name returns the name of the encryptor.
	Name() string
	// Encrypt encrypts data.
	Encrypt(data []byte) ([]byte, error)
	// Decrypt decrypts data.
	Decrypt(data []byte) ([]byte, error)
}

func InvokeEncryptor

func InvokeEncryptor(name string) Encryptor

InvokeEncryptor returns the encryptor registered under name. It panics when no encryptor is registered under that name.

type Signer

type Signer interface {
	// Name returns the name of the signer.
	Name() string
	// Sign signs data.
	Sign(data []byte) ([]byte, error)
	// Verify verifies the signature of data.
	Verify(data []byte, signature []byte) (bool, error)
}

func InvokeSigner

func InvokeSigner(name string) Signer

InvokeSigner returns the signer registered under name. It panics when no signer is registered under that name.

Jump to

Keyboard shortcuts

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