encrypta

package module
Version: v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2019 License: MIT Imports: 8 Imported by: 1

README

Encrypta

GoDoc CircleCI codecov Go Report Card GolangCI

Keybase friendly, encrypts text by public key.

Example

pk, err := encrypta.NewPublicKeyFromKeybase("sawadashota")
if err != nil {
	// error handling
}

enc, err := pk.Encrypt([]byte("I'm encrypted text"))
if err != nil {
	// error handling
}

fmt.Println(enc.Base64Encode())
// Stdout base64 encoded encrypted text

To decode this, private key holder executes following command

$ go run main.go | base64 --decode | keybase pgp decrypt
I'm encrypted text

Documentation

Overview

Package encrypta encrypts text by public key

Example

pk, err := encrypta.NewPublicKeyFromKeybase("sawadashota")
if err != nil {
	// error handling
}

enc, err := pk.Encrypt([]byte("I'm encrypted text"))
if err != nil {
	// error handling
}

fmt.Println(enc.Base64Encode())
// Stdout base64 encoded encrypted text

To decode this, private key holder executes following command

$ go run main.go | base64 --decode | keybase pgp decrypt
I'm encrypted text

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Encrypted

type Encrypted []byte

Encrypted .

func (*Encrypted) Base64Encode

func (e *Encrypted) Base64Encode() string

Base64Encode Encrypted text

func (*Encrypted) String

func (e *Encrypted) String() string

String of Encrypted text

type EncryptionKey

type EncryptionKey interface {
	Encrypt(value []byte) (Encrypted, error)
}

EncryptionKey is public key to encrypt

func NewPublicKey

func NewPublicKey(key io.Reader) (EncryptionKey, error)

NewPublicKey returns new pgpEncryptionKey instance from given key

func NewPublicKeyFromBase64Encoded

func NewPublicKeyFromBase64Encoded(base64EncodedKey string) (EncryptionKey, error)

NewPublicKeyFromBase64Encoded returns new EncryptionKey from base64 encoded key

func NewPublicKeyFromKeybase

func NewPublicKeyFromKeybase(username string, opts ...Option) (EncryptionKey, error)

NewPublicKeyFromKeybase fetches public key from given Keybase's username and returns encryption key

func NewPublicKeyFromURL

func NewPublicKeyFromURL(publicKeyURL string, opts ...Option) (EncryptionKey, error)

NewPublicKeyFromURL fetches public key from given URL and returns encryption key

type Option

type Option func()

Option for changing global variable

func HTTPClientOption

func HTTPClientOption(client *http.Client) Option

HTTPClientOption replace http.Client Supposes tests, GAE environment or etc...

Source Files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL