Files
go-xmlsec/README.md
2015-11-30 16:50:15 -05:00

33 lines
946 B
Markdown

# go-xmlsec
[![Build Status](https://travis-ci.org/crewjam/go-xmlsec.svg?branch=master)](https://travis-ci.org/crewjam/go-xmlsec)
[![](https://godoc.org/github.com/crewjam/go-xmlsec?status.png)](http://godoc.org/github.com/crewjam/go-xmlsec)
A (partial) wrapper for [xmlsec](https://www.aleksey.com/xmlsec).
# Signing (xmldsig)
## Signing Example
key, _ := ioutil.ReadFile("saml.key")
doc, _ := ioutil.ReadAll(os.Stdin)
signedDoc, err := xmldsig.Sign(key, doc, xmldsig.Options{})
os.Stdout.Write(signedDoc)
## Verifying Example
key, _ := ioutil.ReadFile("saml.crt")
doc, _ := ioutil.ReadAll(os.Stdin)
err := xmldsig.Verify(key, doc, xmldsig.Options{})
if err == xmldsig.ErrVerificationFailed {
os.Exit(1)
}
## Decrypting Example
key, _ := ioutil.ReadFile("saml.key")
doc, _ := ioutil.ReadAll(os.Stdin)
plaintextDoc, err := xmlenc.Decrypt(key, doc)
os.Stdout.Write(plaintextDoc)