openpgp

package
v0.1.20 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2022 License: AGPL-3.0 Imports: 5 Imported by: 4

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 *crypto.Key, password []byte) []byte

func BytePublicKey

func BytePublicKey(publicKey *crypto.Key) []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 *crypto.Key) []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) (ciphertext []byte)

*

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

func EncryptKey

func EncryptKey(key []byte, publicKey *crypto.Key) []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 *crypto.Key, password []byte) *crypto.Key

func GetPublicKey

func GetPublicKey(keyPair *crypto.Key) (key *crypto.Key)

func LoadPrivateKey

func LoadPrivateKey(keyValue interface{}, password string) (*crypto.Key, error)

*

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

func LoadPublicKey

func LoadPublicKey(keyValue interface{}) (*crypto.Key, error)

*

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

func ReadSecretKey

func ReadSecretKey(keyPacket []byte, privateKey *crypto.Key, password []byte) *crypto.SessionKey

func Sign

func Sign(privateKey *crypto.Key, passphrase []byte, plaintext []byte) (ciphertext []byte)

func ValidateKey

func ValidateKey(keyPair *crypto.Key, password []byte) bool

func Verify

func Verify(publicKey *crypto.Key, plaintext []byte, ciphertext []byte) (success bool)

func WritePrivateKey

func WritePrivateKey(privateKey *crypto.Key, password []byte) string

func WritePublicKey

func WritePublicKey(publicKey *crypto.Key) string

func WriteSecretKey

func WriteSecretKey(sessionKey *crypto.SessionKey, publicKey *crypto.Key, 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