Documentation
¶
Overview ¶
Package gpg provides a GPG-based object signer for creating armored detached signatures using OpenPGP keys.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrNilSigner is returned when the key provided is nil. ErrNilSigner = errors.New("signer is nil") // ErrNilMessage is returned when a nil message is passed to Sign. ErrNilMessage = errors.New("message is nil") )
Sentinel errors.
Functions ¶
func FromKey ¶
FromKey creates a new GPG signer that uses the provided OpenPGP entity to produce armored detached signatures.
Example ¶
package main
import (
"fmt"
"strings"
"github.com/ProtonMail/go-crypto/openpgp"
"github.com/go-git/x/plugin/objectsigner/gpg"
)
func main() {
// Generate a test key. In practice this would be read from an armored file.
key, err := openpgp.NewEntity("Test User", "", "test@example.com", nil)
if err != nil {
panic(err)
}
signer, err := gpg.FromKey(key)
if err != nil {
panic(err)
}
sig, err := signer.Sign(strings.NewReader("signed commit message\n"))
if err != nil {
panic(err)
}
fmt.Println(strings.Contains(string(sig), "-----BEGIN PGP SIGNATURE-----"))
fmt.Println(strings.Contains(string(sig), "-----END PGP SIGNATURE-----"))
}
Output: true true
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.