encrypt: go.pedge.io/encrypt Index | Files

package encrypt

import "go.pedge.io/encrypt"

Package encrypt provides simplified utilities to encrypt and decrypt data using standard libraries.


Package Files

aes.go encrypt.go rsa.go


const (
    // AES128Bits is the number of bits in an AES-128 key.
    AES128Bits = 128
    // AES192Bits is the number of bits in an AES-192 key.
    AES192Bits = 192
    // AES256Bits is the number of bits in an AES-256 key.
    AES256Bits = 256
    // RSA2048Bits is the number of bits in a 2048-bit RSA key.
    RSA2048Bits = 2048

func DecodeString Uses

func DecodeString(value string) ([]byte, error)

DecodeString is a simple wrapper for base64 decoding.

func EncodeToString Uses

func EncodeToString(value []byte) string

EncodeToString is a simple wrapper for base64 encoding.

func GenerateAESKey Uses

func GenerateAESKey(bits int) (string, error)

GenerateAESKey generates a new AES key for the given number of bits. The returned key will be base64 encoded.

func GenerateRSAKeys Uses

func GenerateRSAKeys(bits int) (string, string, error)

GenerateRSAKeys generates a new public and private (in that order of returned values) key.

type Decryptor Uses

type Decryptor interface {
    // Decrypt decrypts base64 encoded data.
    Decrypt([]byte) ([]byte, error)

Decryptor decrypts data.

type Encryptor Uses

type Encryptor interface {
    // Encrypt encrypts the given data. The returned data will be base64 encoded.
    Encrypt([]byte) ([]byte, error)

Encryptor encrypts data.

func NewRSAEncryptor Uses

func NewRSAEncryptor(publicKey string) (Encryptor, error)

NewRSAEncryptor returns a new RSA Encryptor with the given public key.

type Transformer Uses

type Transformer interface {

Transformer is both an Encryptor and Decryptor.

func NewAESTransformer Uses

func NewAESTransformer(key string) (Transformer, error)

NewAESTransformer creates a new AES Transformer with the given base64 encoded key.

func NewRSATransformer Uses

func NewRSATransformer(privateKey string) (Transformer, error)

NewRSATransformer returns a new RSA Transformer with the given private key.

Package encrypt imports 10 packages (graph) and is imported by 1 packages. Updated 2018-08-26. Refresh now. Tools for package owners.