예제 #1
0
파일: main.go 프로젝트: hyg/com.origin
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)
}