go fmt
This commit is contained in:
parent
d579059ccf
commit
360f954626
10
encrypt.go
10
encrypt.go
@ -13,11 +13,11 @@ import (
|
|||||||
|
|
||||||
type encryptWriter struct {
|
type encryptWriter struct {
|
||||||
multipart *multipart.Writer
|
multipart *multipart.Writer
|
||||||
armored io.WriteCloser
|
armored io.WriteCloser
|
||||||
cleartext io.WriteCloser
|
cleartext io.WriteCloser
|
||||||
|
|
||||||
h textproto.MIMEHeader
|
h textproto.MIMEHeader
|
||||||
to []*openpgp.Entity
|
to []*openpgp.Entity
|
||||||
signed *openpgp.Entity
|
signed *openpgp.Entity
|
||||||
config *packet.Config
|
config *packet.Config
|
||||||
}
|
}
|
||||||
@ -95,8 +95,8 @@ func Encrypt(w io.Writer, h textproto.MIMEHeader, to []*openpgp.Entity, signed *
|
|||||||
return &encryptWriter{
|
return &encryptWriter{
|
||||||
multipart: multipart.NewWriter(w),
|
multipart: multipart.NewWriter(w),
|
||||||
|
|
||||||
h: h,
|
h: h,
|
||||||
to: to,
|
to: to,
|
||||||
signed: signed,
|
signed: signed,
|
||||||
config: config,
|
config: config,
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,7 @@ func ExampleEncrypt() {
|
|||||||
th.SetContentType("text/plain", nil)
|
th.SetContentType("text/plain", nil)
|
||||||
|
|
||||||
// Create a new PGP/MIME writer
|
// Create a new PGP/MIME writer
|
||||||
var ciphertext struct{*message.Writer}
|
var ciphertext struct{ *message.Writer }
|
||||||
cleartext := pgpmime.Encrypt(&ciphertext, textproto.MIMEHeader(th.Header), to, nil, nil)
|
cleartext := pgpmime.Encrypt(&ciphertext, textproto.MIMEHeader(th.Header), to, nil, nil)
|
||||||
|
|
||||||
// Add the PGP/MIME Content-Type header field to the mail header
|
// Add the PGP/MIME Content-Type header field to the mail header
|
||||||
@ -73,7 +73,7 @@ func ExampleSign() {
|
|||||||
bh := mail.NewTextHeader()
|
bh := mail.NewTextHeader()
|
||||||
bh.SetContentType("text/plain", nil)
|
bh.SetContentType("text/plain", nil)
|
||||||
|
|
||||||
var signed struct{*message.Writer}
|
var signed struct{ *message.Writer }
|
||||||
body := pgpmime.Sign(&signed, textproto.MIMEHeader(bh.Header), e, nil)
|
body := pgpmime.Sign(&signed, textproto.MIMEHeader(bh.Header), e, nil)
|
||||||
|
|
||||||
mh.Set("Content-Type", body.ContentType())
|
mh.Set("Content-Type", body.ContentType())
|
||||||
|
12
sign.go
12
sign.go
@ -2,11 +2,11 @@ package pgpmime
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
"crypto"
|
||||||
"io"
|
"io"
|
||||||
"mime"
|
"mime"
|
||||||
"mime/multipart"
|
"mime/multipart"
|
||||||
"net/textproto"
|
"net/textproto"
|
||||||
"crypto"
|
|
||||||
|
|
||||||
"golang.org/x/crypto/openpgp"
|
"golang.org/x/crypto/openpgp"
|
||||||
"golang.org/x/crypto/openpgp/packet"
|
"golang.org/x/crypto/openpgp/packet"
|
||||||
@ -35,10 +35,10 @@ func hashName(h crypto.Hash) string {
|
|||||||
|
|
||||||
type signWriter struct {
|
type signWriter struct {
|
||||||
multipart *multipart.Writer
|
multipart *multipart.Writer
|
||||||
body io.WriteCloser
|
body io.WriteCloser
|
||||||
signature <-chan io.Reader
|
signature <-chan io.Reader
|
||||||
|
|
||||||
h textproto.MIMEHeader
|
h textproto.MIMEHeader
|
||||||
signer *openpgp.Entity
|
signer *openpgp.Entity
|
||||||
config *packet.Config
|
config *packet.Config
|
||||||
}
|
}
|
||||||
@ -59,7 +59,7 @@ func (sw *signWriter) open() error {
|
|||||||
ch <- &b
|
ch <- &b
|
||||||
}()
|
}()
|
||||||
|
|
||||||
sw.body = struct{
|
sw.body = struct {
|
||||||
io.Writer
|
io.Writer
|
||||||
io.Closer
|
io.Closer
|
||||||
}{
|
}{
|
||||||
@ -108,7 +108,7 @@ func (sw *signWriter) Close() error {
|
|||||||
func (sw *signWriter) ContentType() string {
|
func (sw *signWriter) ContentType() string {
|
||||||
return mime.FormatMediaType("multipart/signed", map[string]string{
|
return mime.FormatMediaType("multipart/signed", map[string]string{
|
||||||
"boundary": sw.multipart.Boundary(),
|
"boundary": sw.multipart.Boundary(),
|
||||||
"micalg": "pgp-" + hashName(sw.config.Hash()),
|
"micalg": "pgp-" + hashName(sw.config.Hash()),
|
||||||
"protocol": "application/pgp-signature",
|
"protocol": "application/pgp-signature",
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -118,7 +118,7 @@ func Sign(w io.Writer, h textproto.MIMEHeader, signer *openpgp.Entity, config *p
|
|||||||
return &signWriter{
|
return &signWriter{
|
||||||
multipart: multipart.NewWriter(w),
|
multipart: multipart.NewWriter(w),
|
||||||
|
|
||||||
h: h,
|
h: h,
|
||||||
signer: signer,
|
signer: signer,
|
||||||
config: config,
|
config: config,
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user