Skip to content

kenshaw/pemutil

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

34 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

pemutil

A Go package that provides a light wrapper to load PEM-encoded data, meant to ease the loading, parsing and decoding of PEM data into standard crypto primitives.

Installation

Install the package via the following:

$ go get -u github.com/kenshaw/pemutil

Usage

Please see the GoDoc API page for a full API listing.

The pemutil package can be used similarly to the following:

// _example/main.go
package main

//go:generate openssl genrsa -out rsa-private.pem 2048
//go:generate openssl rsa -in rsa-private.pem -outform PEM -pubout -out rsa-public.pem

import (
	"log"
	"os"

	"github.com/kenshaw/pemutil"
)

func main() {
	// create store and load our private key
	keyset, err := pemutil.LoadFile("rsa-private.pem")
	if err != nil {
		log.Fatal(err)
	}

	// do something with keyset.RSAPrivateKey()

	// get pem data and write to disk
	buf, err := keyset.Bytes()
	if err != nil {
		log.Fatal(err)
	}
	os.Stdout.Write(buf)
}

About

pemutil is a Golang package that provides a very light wrapper around loading PEM encoded data.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages