crypto

package
v0.4.4 Latest Latest
Warning

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

Go to latest
Published: Feb 5, 2022 License: AGPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	NONCE_SIZE       = 12
	KEY_ENTROPY_SIZE = 32
	KEY_SIZE         = 16
)

Functions

func Decrypt

func Decrypt(key Key, data string) (string, error)

Decrypt takes a Key and AESGCM encrypted IV+ciphertext data and returns the plaintext.

@callable: crypto.decrypt @param: key @Key @param: data @String @retval: plaintext @String @retval: err @Error

@usage: p, err = crypto.decrypt(key, data)

func Encrypt

func Encrypt(key Key, data string) (string, error)

Encrypt takes a Key and some data and returns the AESGCM encrypted IV+ciphertext.

@callable: crypto.encrypt @param: key @Key @param: data @String @retval: ciphertext @String @retval: err @Error

@usage: c, err = crypto.encrypt(key, data)

func Include

func Include() script.Option

Include the crypto library in a script environment.

func Library

func Library() script.Library

Library prepares a new crypto library for use within a script environment.

Types

type Key

type Key struct {
	// contains filtered or unexported fields
}

Key is a basic type alias for string that will let us provide linting within scripts WARNING: This is NOT how you should normally handle keys in go.

func CreateKey

func CreateKey(value string) (Key, error)

CreateKey creates a new Key object to be passed around given the value. Will also error if passed value is not valid base64/the key is not KEY_SIZE bytes.

func GenerateKey

func GenerateKey() (Key, error)

GenerateKey creates a new Key object to be passed around.

@callable: crypto.generateKey @retval: key @Key @retval: err @Error

@usage: k, err = crypto.generateKey()

func ParseParam

func ParseParam(parser script.ArgParser, index int) (Key, error)

ParseParam from starlark input

func (Key) Freeze

func (k Key) Freeze()

Freeze is a no-op since the underlying file is safe for concurrent use.

func (Key) Hash

func (k Key) Hash() (uint32, error)

Hash will error since the file type is not intended to be hashable.

func (Key) String

func (k Key) String() string

String returns the name of the file.

func (Key) Truth

func (k Key) Truth() starlark.Bool

Truth value of a file is True if the file is non-nil

func (Key) Type

func (k Key) Type() string

Type returns 'file' to indicate the type of the file within starlark.

Jump to

Keyboard shortcuts

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