godh

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2023 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CRYPTO_DH_KEY_LENGTH = 32
)

Variables

This section is empty.

Functions

This section is empty.

Types

type CryptoDH

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

func NewCryptoDH

func NewCryptoDH(pri ...[32]byte) (dh *CryptoDH)

创建DH加密对象并随机生成私钥和对应公钥(如果pri参数为空)

func (*CryptoDH) GetCurve25519KeyPair

func (dh *CryptoDH) GetCurve25519KeyPair() (pri, pub [32]byte)

func (*CryptoDH) GetCurve25519KeyPairBase64

func (dh *CryptoDH) GetCurve25519KeyPairBase64() (priBase64, pubBase64 string)

func (*CryptoDH) GetPrivateKey

func (dh *CryptoDH) GetPrivateKey() [32]byte

func (*CryptoDH) GetPrivateKeyBase64

func (dh *CryptoDH) GetPrivateKeyBase64() string

func (*CryptoDH) GetPublicKey

func (dh *CryptoDH) GetPublicKey() [32]byte

func (*CryptoDH) GetPublicKeyBase64

func (dh *CryptoDH) GetPublicKeyBase64() string

func (*CryptoDH) GetShareKey

func (dh *CryptoDH) GetShareKey() [32]byte

func (*CryptoDH) GetShareKeyBase64

func (dh *CryptoDH) GetShareKeyBase64() string

func (*CryptoDH) ScalarMult

func (dh *CryptoDH) ScalarMult(pub [32]byte) [32]byte

pub 对方的公钥(32字节byte数组) 返回key:自己的私钥+对方公钥经DH算法计算出来的加密KEY

func (*CryptoDH) ScalarMultBase64

func (dh *CryptoDH) ScalarMultBase64(base string) string

base 对方的公钥(base64编码) 返回key:自己的私钥+对方公钥经DH算法计算出来的加密KEY(base64编码)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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