Пример #1
0
func Sign(plaintext string) string {
	secringFile, _ := os.Open("C:/Users/huangyg/Desktop/huangyg.sec")
	defer secringFile.Close()
	secring, _ := openpgp.ReadArmoredKeyRing(secringFile)
	myPrivateKey := getKeyByEmail(secring, "*****@*****.**")

	myPrivateKey.PrivateKey.Decrypt([]byte("passphrase"))

	ret := ""
	buf := bytes.NewBufferString(ret)
	openpgp.ArmoredDetachSignText(buf, myPrivateKey, bytes.NewBufferString(plaintext), nil)
	ret = buf.String()

	return ret
}
Пример #2
0
// Sign signs the given message and writes the ascii armored OpenPGP signature
// to w.
func (s *gpgSigner) Sign(w io.Writer, message io.Reader) error {
	return openpgp.ArmoredDetachSignText(w, s.signer, message, nil)
}