security

package
v0.0.0-...-58f9d26 Latest Latest
Warning

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

Go to latest
Published: Jul 7, 2016 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidType = errors.New("Input must be either a Serializer or byte slice!")
	ErrInvalidData = errors.New("Input is invalid!")
)

These are the errors to be expected when things go awry during the encryption/cipher creation process

Functions

func DecryptData

func DecryptData(src []byte, dst Serializer) ([]byte, error)

DecryptData takes a destination interface{} and a byte slice and decrypts the bytes into the destination using a GCM cipher block. If dst is not nil, the decrypted data will be passed into the Serializer's Deserialize method. This method returns the decrypted bytes regardless.

func EncryptData

func EncryptData(value interface{}) ([]byte, error)

EncryptData takes a value and encrypts it using a GCM cipher block

func GenerateCSRFToken

func GenerateCSRFToken() string

GenerateCSRFToken generates and returns a cryptographically random token for use in cross-site request forgery protection

func SetEncryptionBlock

func SetEncryptionBlock(f func([]byte) cipher.Block) error

SetEncryptionBlock allows the use of custom cipher blocks. All cipher blocks are wrapped in GCM

Types

type Serializer

type Serializer interface {
	Serialize() []byte
	Deserialize([]byte)
}

Serializer is an interface that allows one to encrypt/decrypt data directly from/to a struct

Jump to

Keyboard shortcuts

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