crypt

package module
v0.0.0-...-ee94bd8 Latest Latest
Warning

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

Go to latest
Published: Jul 1, 2024 License: Apache-2.0 Imports: 7 Imported by: 6

README

Go Reference

ugent-library/crypt

Package crypt contains easy to use best practice crypto and random value functions.

Install

go get -u github.com/ugent-library/crypt

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Decrypt

func Decrypt(key, ciphertext []byte) ([]byte, error)

Decrypt decrypts data encrypted with Encrypt using 256-bit AES-GCM and checks that the data wasn't altered.

func DecryptString

func DecryptString(key []byte, encodedtext string) (string, error)

func DecryptValue

func DecryptValue(key []byte, encodedtext string, v any) error

func Encrypt

func Encrypt(key, plaintext []byte) ([]byte, error)

Encrypt encrypts data using 256-bit AES-GCM. The resulting ciphertext provides a check that the data hasn't been altered.

func EncryptString

func EncryptString(key []byte, plaintext string) (string, error)

func EncryptValue

func EncryptValue(key []byte, v any) (string, error)

func RandomBytes

func RandomBytes(n int) ([]byte, error)

func RandomString

func RandomString(n int) (string, error)

Types

type Crypt

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

func New

func New(key []byte) *Crypt

func (*Crypt) Decrypt

func (c *Crypt) Decrypt(ciphertext []byte) ([]byte, error)

func (*Crypt) DecryptString

func (c *Crypt) DecryptString(encodedtext string) (string, error)

func (*Crypt) DecryptValue

func (c *Crypt) DecryptValue(encodedtext string, v any) error

func (*Crypt) Encrypt

func (c *Crypt) Encrypt(plaintext []byte) ([]byte, error)

func (*Crypt) EncryptString

func (c *Crypt) EncryptString(plaintext string) (string, error)

func (*Crypt) EncryptValue

func (c *Crypt) EncryptValue(v any) (string, error)

Jump to

Keyboard shortcuts

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