Involved Source Files
Package pem implements the PEM data encoding, which originated in Privacy
Enhanced Mail. The most common use of PEM encoding today is in TLS keys and
certificates. See RFC 1421.
Package-Level Type Names (total 2, in which 1 are exported)
/* sort exporteds by: | */
A Block represents a PEM encoded structure.
The encoded form is:
-----BEGIN Type-----
Headers
base64-encoded Bytes
-----END Type-----
where Headers is a possibly empty sequence of Key: Value lines.
// The decoded bytes of the contents. Typically a DER encoded ASN.1 structure.
// Optional headers.
// The type, taken from the preamble (i.e. "RSA PRIVATE KEY").
func Decode(data []byte) (p *Block, rest []byte)
func crypto/x509.EncryptPEMBlock(rand io.Reader, blockType string, data, password []byte, alg x509.PEMCipher) (*Block, error)
func decodeError(data, rest []byte) (*Block, []byte)
func Encode(out io.Writer, b *Block) error
func EncodeToMemory(b *Block) []byte
func crypto/x509.DecryptPEMBlock(b *Block, password []byte) ([]byte, error)
func crypto/x509.IsEncryptedPEMBlock(b *Block) bool
Package-Level Functions (total 7, in which 3 are exported)
Decode will find the next PEM formatted block (certificate, private key
etc) in the input. It returns that block and the remainder of the input. If
no PEM data is found, p is nil and the whole of the input is returned in
rest.
Encode writes the PEM encoding of b to out.
EncodeToMemory returns the PEM encoding of b.
If b has invalid headers and cannot be encoded,
EncodeToMemory returns nil. If it is important to
report details about this error case, use Encode instead.
getLine results the first \r\n or \n delineated line from the given byte
array. The line does not include trailing whitespace or the trailing new
line bytes. The remainder of the byte array (also not including the new line
bytes) is also returned and this will always be smaller than the original
argument.
removeSpacesAndTabs returns a copy of its input with all spaces and tabs
removed, if there were any. Otherwise, the input is returned unchanged.
The base64 decoder already skips newline characters, so we don't need to
filter them out here.