emersion / go-msgauth

🔏 A Go library and tools for DKIM, DMARC and Authentication-Results
MIT License
162 stars 51 forks source link

Extract only signature instead of complete body #34

Closed err-him closed 3 years ago

err-him commented 3 years ago

Hi, this is not exactly an issue but an improvement. There should be a flag where if someone only needs the DKIM signature instead of complete data (header + body).

r := strings.NewReader(mailString)

options := &dkim.SignOptions{
    Domain: "example.org",
    Selector: "brisbane",
    Signer: privateKey,
}

var b bytes.Buffer
if err := dkim.Sign(&b, r, options); err != nil {
    log.Fatal(err)
}

This provides complete data.

options := &dkim.SignOptions{
        Domain:                 domain,
        Selector:               defaultKeySelector,
        Signer:                 privateKey,
    }

Here we can add another field like dkimSign : true which only return the signature.

foxcpp commented 3 years ago

See https://godoc.org/github.com/emersion/go-msgauth/dkim#Signer.Signature