packager

package
v0.0.0-...-015e77e Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2022 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Version is the current package fmt ver.
	Version = "0.0.1"

	// InvalidToken is an invalid sparse token.
	InvalidToken = ""
)

Variables

This section is empty.

Functions

func EncodePackage

func EncodePackage(encoderID, token string, cipher, encoded []byte, compressed bool) ([]byte, error)

EncodePackage returns a valid binary enc package for storage.

Types

type Format

type Format string

Format is the package fmt. Currently only secure & sparse formats are supported.

const (
	// Secure indicates the package contains a fully encrypted JSON object.
	Secure Format = "secure"

	// Sparse indicates the package supports sparse decryption.
	Sparse Format = "sparse"
)

func (Format) Valid

func (f Format) Valid() bool

Valid returns true if the fmt is valid.

type Package

type Package struct {
	Version    string
	Format     Format
	Compressed bool
	EncoderID  string
	Token      string
	Cipher     []byte
	Encoded    []byte
}

Package is returned by DecodePackage.

- Secure: If the package fmt Format is Secure, Package contains the encrypted ciphertext Cipher containing a fully encoded JSON object.

- Sparse: If the package Format is Sparse, the encrypted ciphertext Cipher contains a lookup table of secure values. Encoded contains a plaintext enc JSON with its secure fields removed and replaced with a secure lookup token consisting of a prefixed EncoderID with the fmt "[prefix]-[encoder id]" (SEE: NewLookupToken) and an index into the lookup table.

func DecodePackage

func DecodePackage(bytes []byte) (*Package, error)

DecodePackage takes packaged data and returns the ciphertext and encoding block.

func (*Package) Valid

func (p *Package) Valid() error

Valid returns true if the package fmt is valid.

Jump to

Keyboard shortcuts

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