godh

package
v1.0.9 Latest Latest
Warning

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

Go to latest
Published: Aug 5, 2020 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 {
	ShareKey         [CRYPTO_DH_KEY_LENGTH]byte //共享密钥(用于双方加密/解密)
	PrivateKey       [CRYPTO_DH_KEY_LENGTH]byte //私钥
	PublicKey        [CRYPTO_DH_KEY_LENGTH]byte //公钥
	ShareKeyBase64   string                     //共享密钥BASE64字符串
	PublicKeyBase64  string                     //公钥BASE64字符串
	PrivateKeyBase64 string                     //私钥BASE64字符串
}

func NewCryptoDH

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

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

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