crypt

package
v0.5.42 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2025 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Crypt

type Crypt interface {
	GenKeyPair() ([]byte, []byte, error) // 生成公钥和私钥,返回公钥和私钥的字节数组
	Init() error                         // 初始化
	Sign(raw string) (string, error)     // 签名
	Verify(plaintext, sign string) error // 验证签名
}

type Ed25519

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

func NewEd25519

func NewEd25519(opts ...Ed25519Option) *Ed25519

func (*Ed25519) GenKeyPair

func (e *Ed25519) GenKeyPair() ([]byte, []byte, error)

func (*Ed25519) Init

func (e *Ed25519) Init() error

func (*Ed25519) LoadPrivateKey

func (e *Ed25519) LoadPrivateKey() (*ed25519.PrivateKey, error)

func (*Ed25519) LoadPublicKey

func (e *Ed25519) LoadPublicKey() (*ed25519.PublicKey, error)

func (*Ed25519) Provide

func (e *Ed25519) Provide(ctx context.Context) interface{}

func (*Ed25519) Sign

func (e *Ed25519) Sign(raw string) (string, error)

func (*Ed25519) Verify

func (e *Ed25519) Verify(plaintext, sign string) error

type Ed25519Option

type Ed25519Option func(*Ed25519Options)

func WithEd25519PrivateKey

func WithEd25519PrivateKey(privateKey string) Ed25519Option

func WithEd25519PrivateKeyFile

func WithEd25519PrivateKeyFile(privateKeyFile string) Ed25519Option

func WithEd25519PublicKey

func WithEd25519PublicKey(publicKey string) Ed25519Option

func WithEd25519PublicKeyFile

func WithEd25519PublicKeyFile(publicKeyFile string) Ed25519Option

type Ed25519Options

type Ed25519Options struct {
	PrivateKey     string
	PrivateKeyFile string
	PublicKey      string
	PublicKeyFile  string
}

type Rsa

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

func NewRsa

func NewRsa(opts ...RsaOption) *Rsa

func (*Rsa) GenKeyPair

func (r *Rsa) GenKeyPair() ([]byte, []byte, error)

func (*Rsa) Init

func (r *Rsa) Init() error

func (*Rsa) LoadPrivateKey

func (r *Rsa) LoadPrivateKey() (*rsa.PrivateKey, error)

func (*Rsa) LoadPublicKey

func (r *Rsa) LoadPublicKey() (*rsa.PublicKey, error)

func (*Rsa) Provide

func (r *Rsa) Provide(ctx context.Context) interface{}

func (*Rsa) Sign

func (r *Rsa) Sign(raw string) (string, error)

func (*Rsa) Verify

func (r *Rsa) Verify(plaintext, sign string) error

type RsaOption

type RsaOption func(*RsaOptions)

func WithPrivateKey

func WithPrivateKey(privateKey string) RsaOption

func WithPrivateKeyFile

func WithPrivateKeyFile(privateKeyFile string) RsaOption

func WithPublicKey

func WithPublicKey(publicKey string) RsaOption

func WithPublicKeyFile

func WithPublicKeyFile(publicKeyFile string) RsaOption

type RsaOptions

type RsaOptions struct {
	PublicKey      string
	PublicKeyFile  string
	PrivateKey     string
	PrivateKeyFile string
}

Jump to

Keyboard shortcuts

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