encrypta

package module
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2023 License: MIT Imports: 8 Imported by: 4

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...

Jump to

Keyboard shortcuts

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