encoding

package
v0.0.0-...-93fbde9 Latest Latest
Warning

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

Go to latest
Published: May 15, 2022 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package encoding defines the various encoding Algorithms supported by the gormcrypto package

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterAlgo

func RegisterAlgo(name string, creator func(map[string]interface{}) Algorithm)

RegisterAlgo adds an Algorithm to the internal algos map so it can be used in YAML configs

func SupportedAlgos

func SupportedAlgos() []string

SupportedAlgos returns a list of registered Algorithms that can be used in YAML configs

Types

type ASCII85

type ASCII85 struct {
	Algorithm
}

ASCII85 supports ASCII85 encoding of arbitrary data

func (ASCII85) Config

func (ASCII85) Config() map[string]interface{}

Config converts an Algorthim's internal configuration into a map for export

func (ASCII85) Decode

func (ASCII85) Decode(encoded []byte) ([]byte, error)

Decode ::: ASCII85

func (ASCII85) Encode

func (ASCII85) Encode(raw []byte) ([]byte, error)

Encode ::: ASCII85

func (ASCII85) Name

func (ASCII85) Name() string

Name identifies the Algorithm as a string for exporting configurations

type Algorithm

type Algorithm interface {
	// Name identifies the Algorithm as a string for exporting configurations
	Name() string
	// Config converts an Algorthim's internal configuration into a map for export
	Config() map[string]interface{}
	// Encode transforms a binary value into a text encoding that can safely be serialized/stored.
	Encode([]byte) ([]byte, error)
	// Decode transforms a text encoding into a raw binary value which can be used for decryption/signature verification.
	Decode([]byte) ([]byte, error)
}

Algorithm is a bad name for the core interface all gormcrypto encodings implement. The name was chosen for consistency more than anything. A type implementing encoding.Algorithm will convert a value between its raw binary and encoded text forms, in a manner consistent with its type. The types implemented here wrap the Go standard library's various encoding packages.

func FromYaml

func FromYaml(name string, config map[string]interface{}) Algorithm

FromYaml configures an Algorithm automatically based on a name and a configuration map

type Base32

type Base32 struct {
	Algorithm
}

Base32 supports Base32 encoding of arbitrary data

func (Base32) Config

func (Base32) Config() map[string]interface{}

Config converts an Algorthim's internal configuration into a map for export

func (Base32) Decode

func (Base32) Decode(encoded []byte) ([]byte, error)

Decode ::: Base32

func (Base32) Encode

func (Base32) Encode(raw []byte) ([]byte, error)

Encode ::: Base32

func (Base32) Name

func (Base32) Name() string

Name identifies the Algorithm as a string for exporting configurations

type Base64

type Base64 struct {
	Algorithm
}

Base64 supports Base64 encoding of arbitrary data

func (Base64) Config

func (Base64) Config() map[string]interface{}

Config converts an Algorthim's internal configuration into a map for export

func (Base64) Decode

func (Base64) Decode(encoded []byte) ([]byte, error)

Decode ::: Base64

func (Base64) Encode

func (Base64) Encode(raw []byte) ([]byte, error)

Encode ::: Base64

func (Base64) Name

func (Base64) Name() string

Name identifies the Algorithm as a string for exporting configurations

type Hex

type Hex struct {
	Algorithm
}

Hex supports Hex encoding of arbitrary data

func (Hex) Config

func (Hex) Config() map[string]interface{}

Config converts an Algorthim's internal configuration into a map for export

func (Hex) Decode

func (Hex) Decode(encoded []byte) ([]byte, error)

Decode ::: Hex

func (Hex) Encode

func (Hex) Encode(raw []byte) ([]byte, error)

Encode ::: Hex

func (Hex) Name

func (Hex) Name() string

Name identifies the Algorithm as a string for exporting configurations

type PEM

type PEM struct {
	Algorithm
}

PEM supports PEM encoding of aritrary data

func (PEM) Config

func (PEM) Config() map[string]interface{}

Config converts an Algorthim's internal configuration into a map for export

func (PEM) Decode

func (h PEM) Decode(encoded []byte) ([]byte, error)

Decode ::: PEM

func (PEM) Encode

func (h PEM) Encode(raw []byte) ([]byte, error)

Encode ::: PEM

func (PEM) Name

func (PEM) Name() string

Name identifies the Algorithm as a string for exporting configurations

Jump to

Keyboard shortcuts

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