libp2p

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2021 License: AGPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildSecretKey

func BuildSecretKey(keyValue string) string

*

  • 生成指定字符串的对称密码

func BytePrivateKey

func BytePrivateKey(privateKey *ecdh.PrivateKey, password []byte) []byte

func BytePublicKey

func BytePublicKey(publicKey *ecdh.PublicKey) []byte

func Decrypt

func Decrypt(keyValue interface{}, passphrase []byte, ciphertext []byte) []byte

*

  • 非对称解密 *
  • @param privkey 解密的密钥
  • @param ciphertext 已经加密的数据
  • @return 解密后的明文
  • @throws EncryptException

func DecryptKey

func DecryptKey(keyValue []byte, privateKey *ecdh.PrivateKey) []byte

func DecryptSymmetrical

func DecryptSymmetrical(key []byte, ciphertext []byte) []byte

*

  • 非对称解密 *
  • @param key 解密的密钥
  • @param raw 已经加密的数据
  • @return 解密后的明文
  • @throws EncryptException

func Encrypt

func Encrypt(keyValue interface{}, plaintext []byte) []byte

*

  • 非对称加密 *
  • @param key 加密的密钥
  • @param data 待加密的明文数据
  • @return 加密后的数据
  • @throws EncryptException

func EncryptKey

func EncryptKey(key []byte, publicKey *ecdh.PublicKey) []byte

func EncryptSymmetrical

func EncryptSymmetrical(key []byte, plaintext []byte) []byte

*

  • 对称加密 *
  • @param key 加密的密钥
  • @param data 待加密的明文数据
  • @return 加密后的数据
  • @throws EncryptException

func GenerateKeyPair

func GenerateKeyPair(keyType string, passphrase []byte, armored bool, name string, email string) interface{}

*

  • 生成非对称的密钥对 *
  • @return

func GenerateSecretKey

func GenerateSecretKey(size int) (sessionKey interface{})

*

  • 生成随机对称秘钥 *
  • @param algorithm
  • @return
  • @throws NoSuchAlgorithmException

func GetPrivateKey

func GetPrivateKey(keyPair *ecdh.PrivateKey, password []byte) *ecdh.PrivateKey

func GetPublicKey

func GetPublicKey(keyPair *ecdh.PrivateKey) (key *ecdh.PublicKey)

func LoadPrivateKey

func LoadPrivateKey(keyValue interface{}, password string) *ecdh.PrivateKey

*

  • 从证书中的私钥二进制字符串表示中还原私钥 * *
  • @param keyValue
  • @return

func LoadPublicKey

func LoadPublicKey(keyValue interface{}) *ecdh.PublicKey

*

  • 从公钥字符串,Key,KeyRing,表示中还原公钥 * *
  • @param keyValue
  • @return
  • @throws NoSuchAlgorithmException
  • @throws InvalidKeySpecException

func ReadSecretKey

func ReadSecretKey(keyPacket []byte, privateKey *ecdh.PrivateKey, password []byte) []byte

func Sign

func Sign(privateKey *ed25519.PrivateKey, passphrase []byte, plaintext []byte) (ciphertext []byte)

func ValidateKey

func ValidateKey(keyPair *ecdh.PublicKey, password []byte) bool

func Verify

func Verify(publicKey *ed25519.PublicKey, plaintext []byte, ciphertext []byte) (success bool)

func WritePrivateKey

func WritePrivateKey(privateKey *ecdh.PrivateKey, password []byte) string

func WritePublicKey

func WritePublicKey(publicKey *ecdh.PublicKey) string

func WriteSecretKey

func WriteSecretKey(sessionKey []byte, publicKey *ecdh.PublicKey, password []byte) []byte

* 对对称密钥用对方公钥加密

Types

This section is empty.

Jump to

Keyboard shortcuts

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