openpgp

package
v0.1.28 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2025 License: AGPL-3.0 Imports: 7 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BytePrivateKey

func BytePrivateKey(key *crypto.Key, password []byte) (bs []byte, err error)

func BytePublicKey

func BytePublicKey(key *crypto.Key) (bs []byte, err error)

func Decrypt

func Decrypt(key *crypto.Key, ciphertext []byte) (decrypted []byte, err error)

*

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

func DecryptKey

func DecryptKey(keyValue []byte, privateKey *crypto.Key) (decrypted []byte, err error)

func DecryptSymmetrical

func DecryptSymmetrical(password []byte, ciphertext []byte) (decrypted []byte, err error)

*

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

func Encrypt

func Encrypt(key *crypto.Key, plaintext []byte) (ciphertext []byte, err error)

*

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

func EncryptKey

func EncryptKey(key []byte, publicKey *crypto.Key) (ciphertext []byte, err error)

func EncryptSymmetrical

func EncryptSymmetrical(password []byte, plaintext []byte) (armored []byte, err error)

*

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

func GenerateKeyPair

func GenerateKeyPair(keyType string, passphrase []byte, name string, email string) (keypair *crypto.Key, err error)

*

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

func GenerateSecretKey

func GenerateSecretKey(size int) (sessionKey interface{}, err error)

*

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

func GetPrivateKey

func GetPrivateKey(keyPair *crypto.Key, password []byte) (key *crypto.Key, err error)

func GetPublicKey

func GetPublicKey(keyPair *crypto.Key) (key *crypto.Key, err error)

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 Sign

func Sign(key *crypto.Key, plaintext []byte) (signature []byte, err error)

func ValidateKey

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

func Verify

func Verify(publicKey *crypto.Key, data []byte, signature []byte) (success bool, err error)

func WritePublicKey

func WritePublicKey(publicKey *crypto.Key) (base64 string, err error)

Types

This section is empty.

Jump to

Keyboard shortcuts

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