pwpem

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2018 License: MIT Imports: 4 Imported by: 0

README

pwpem GoDoc Build Status Go Report Card

encrypt & decrypt PEM block(s) with passwords

install

go get github.com/kasperlewau/pwpem

usage

import "github.com/kasperlewau/pwpem"

pem := []byte("-----BEGIN PRIVATE KEY-----\nbase64encodedprivatekey....")
pass := []byte("password")

e, err := pwpem.Encrypt(pem, pass)
fmt.Println(string(e)); // "-----BEGIN PRIVATE KEY-----\nProc-Type: 4,ENCRYPTED\nDEK-Info: AES-256....."

d, err := pwpem.Decrypt(e, pass)
fmt.Println(string(d)); // "-----BEGIN PRIVATE KEY-----\nbase64encodedprivatekey....")

Documentation

Overview

Package pwpem encrypts & decrypts PEM blocks with a password

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNoBlock signals that there was no block to be encrypted/decrypted in the given byte slice
	ErrNoBlock = errors.New("pwpem: no block found")
	// ErrBlockEncrypted signals that the first block is already encrypted
	ErrBlockEncrypted = errors.New("pwpem: first block is already encrypted")
)

Functions

func Decrypt

func Decrypt(c, p []byte) ([]byte, error)

Decrypt decrypts the first encountered PEM block in the byte slice with password.

The full decrypted chain is returned as a byte slice.

func Encrypt

func Encrypt(c, p []byte) ([]byte, error)

Encrypt encrypts the first encountered PEM block in the byte slice with password.

The full encrypted chain is returned as a byte slice.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL