pem

package standard library
go1.23rc1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 21, 2024 License: BSD-3-Clause Imports: 6 Imported by: 61,050

Documentation

Overview

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.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func Encode

func Encode(out io.Writer, b *Block) error

Encode writes the PEM encoding of b to out.

Example
package main

import (
	"encoding/pem"
	"log"
	"os"
)

func main() {
	block := &pem.Block{
		Type: "MESSAGE",
		Headers: map[string]string{
			"Animal": "Gopher",
		},
		Bytes: []byte("test"),
	}

	if err := pem.Encode(os.Stdout, block); err != nil {
		log.Fatal(err)
	}
}
Output:
-----BEGIN MESSAGE-----
Animal: Gopher

dGVzdA==
-----END MESSAGE-----

func EncodeToMemory

func EncodeToMemory(b *Block) []byte

EncodeToMemory returns the PEM encoding of b.