dh

package
v1.0.1023 Latest Latest
Warning

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

Go to latest
Published: Aug 8, 2022 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// 获取 Cipher 类型
	GetCipherFromName = cryptobin_pkcs8.GetCipherFromName
	// 获取 hash 类型
	GetHashFromName = cryptobin_pkcs8.GetHashFromName
)
View Source
var (
	ErrKeyMustBePEMEncoded = errors.New("invalid key: Key must be a PEM encoded PKCS1 or PKCS8 key")
	ErrNotPrivateKey       = errors.New("key is not a valid dh private key")
	ErrNotPublicKey        = errors.New("key is not a valid dh public key")
)
View Source
var PEMCiphers = map[string]x509.PEMCipher{
	"DESCBC":     x509.PEMCipherDES,
	"DESEDE3CBC": x509.PEMCipher3DES,
	"AES128CBC":  x509.PEMCipherAES128,
	"AES192CBC":  x509.PEMCipherAES192,
	"AES256CBC":  x509.PEMCipherAES256,
}

pem 加密方式

Functions

This section is empty.

Types

type Dh

type Dh struct {

	// 错误
	Error error
	// contains filtered or unexported fields
}

*

  • dh *
  • @create 2022-8-7
  • @author deatil

func New

func New() Dh

构造函数

func NewDh

func NewDh() Dh

构造函数

func (Dh) CreateKdfPrivateKeyWithPassword

func (this Dh) CreateKdfPrivateKeyWithPassword(password string, opts ...any) Dh

生成私钥带密码 pem 数据 CreateKdfPrivateKeyWithPassword("123", "AES256CBC", "SHA256")

func (Dh) CreatePbePrivateKeyWithPassword

func (this Dh) CreatePbePrivateKeyWithPassword(password string, alg string) Dh

生成 PKCS8 私钥带密码 pem 数据

func (Dh) CreatePrivateKey

func (this Dh) CreatePrivateKey() Dh

生成私钥 pem 数据 使用: obj := New().GenerateKey("P2048") priKey := obj.CreatePrivateKey().ToKeyString()

func (Dh) CreatePrivateKeyWithPassword

func (this Dh) CreatePrivateKeyWithPassword(password string, opts ...any) Dh

生成 PKCS8 私钥带密码 pem 数据 CreatePrivateKeyWithPassword("123", "AES256CBC", "SHA256")

func (Dh) CreatePublicKey

func (this Dh) CreatePublicKey() Dh

生成公钥 pem 数据

func (Dh) CreateSecret

func (this Dh) CreateSecret() Dh

根据公钥和私钥生成密钥

func (Dh) FromPrivateKey

func (this Dh) FromPrivateKey(key []byte) Dh

私钥

func (Dh) FromPrivateKeyWithPassword

func (this Dh) FromPrivateKeyWithPassword(key []byte, password string) Dh

私钥带密码

func (Dh) FromPublicKey

func (this Dh) FromPublicKey(key []byte) Dh

公钥

func (Dh) GenerateKey

func (this Dh) GenerateKey(name string) Dh

生成密钥

func (Dh) GetError

func (this Dh) GetError() error

获取错误

func (Dh) GetKeyData

func (this Dh) GetKeyData() []byte

获取 keyData

func (Dh) GetPrivateKey

func (this Dh) GetPrivateKey() *dh.PrivateKey

获取 PrivateKey

func (Dh) GetPublicKey

func (this Dh) GetPublicKey() *dh.PublicKey

获取 PublicKey

func (Dh) MakePublicKey

func (this Dh) MakePublicKey() Dh

生成公钥

func (Dh) OnError

func (this Dh) OnError(fn ErrorFunc) Dh

引出错误信息

func (Dh) ParsePrivateKeyFromPEM

func (this Dh) ParsePrivateKeyFromPEM(key []byte) (crypto.PrivateKey, error)

解析私钥

func (Dh) ParsePrivateKeyFromPEMWithPassword

func (this Dh) ParsePrivateKeyFromPEMWithPassword(key []byte, password string) (crypto.PrivateKey, error)

解析私钥带密码

func (Dh) ParsePublicKeyFromPEM

func (this Dh) ParsePublicKeyFromPEM(key []byte) (crypto.PublicKey, error)

解析公钥

func (Dh) ToBase64String

func (this Dh) ToBase64String() string

输出Base64

func (Dh) ToBytes

func (this Dh) ToBytes() []byte

输出字节

func (Dh) ToHexString

func (this Dh) ToHexString() string

输出Hex

func (Dh) ToKeyBytes

func (this Dh) ToKeyBytes() []byte

私钥/公钥

func (Dh) ToKeyString

func (this Dh) ToKeyString() string

私钥/公钥

func (Dh) ToString

func (this Dh) ToString() string

输出字符

func (Dh) WithError

func (this Dh) WithError(err error) Dh

设置错误

func (Dh) WithKeyData

func (this Dh) WithKeyData(data []byte) Dh

设置 keyData

func (Dh) WithPrivateKey

func (this Dh) WithPrivateKey(data *dh.PrivateKey) Dh

设置 PrivateKey

func (Dh) WithPublicKey

func (this Dh) WithPublicKey(data *dh.PublicKey) Dh

设置 PublicKey

type ErrorFunc

type ErrorFunc = func(error)

错误方法

type Opts

type Opts = cryptobin_pkcs8.Opts

配置

type PBKDF2Opts

type PBKDF2Opts = cryptobin_pkcs8.PBKDF2Opts

PBKDF2 配置

type ScryptOpts

type ScryptOpts = cryptobin_pkcs8.ScryptOpts

Scrypt 配置

Jump to

Keyboard shortcuts

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