pkcs

package
v1.0.4016 Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2024 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cipher

type Cipher interface {
	// oid
	OID() asn1.ObjectIdentifier

	// 值大小
	KeySize() int

	// 是否有 KeyLength
	HasKeyLength() bool

	// 密码是否需要 Bmp 处理
	NeedBmpPassword() bool

	// 加密, 返回: [加密后数据, 参数, error]
	Encrypt(rand io.Reader, key, plaintext []byte) ([]byte, []byte, error)

	// 解密
	Decrypt(key, params, ciphertext []byte) ([]byte, error)
}

加密接口

type Sym

type Sym[T any] struct {
	// contains filtered or unexported fields
}

泛型适配对称加密 T 为对应参数结构

func NewSym

func NewSym[T any](cipher Cipher) *Sym[T]

func (*Sym[T]) Decrypt

func (this *Sym[T]) Decrypt(key []byte, params T, ciphertext []byte) ([]byte, error)

解密

func (*Sym[T]) Encrypt

func (this *Sym[T]) Encrypt(rand io.Reader, key, plaintext []byte) (encrypted []byte, params T, err error)

加密

func (*Sym[T]) OID

func (this *Sym[T]) OID() asn1.ObjectIdentifier

oid

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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