go-pgp/pgp/sign.go
2024-07-25 16:31:58 +02:00

18 lines
335 B
Go

package pgp
import (
"bytes"
"golang.org/x/crypto/openpgp"
)
func Sign(entity *openpgp.Entity, message []byte) ([]byte, error) {
writer := new(bytes.Buffer)
reader := bytes.NewReader(message)
err := openpgp.ArmoredDetachSign(writer, entity, reader, nil)
if err != nil {
return []byte{}, err
}
return writer.Bytes(), nil
}