crypto

package
v1.0.31 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2022 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Decrypt

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

Decrypt decrypts an encrypted value when the key is equal to the key used in the Encrypt method

func Encrypt

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

Encrypt encrypts data using AES-256 with the key provided Key must have a minimum of 16 chars

func HashSha512String

func HashSha512String(in string) string

HashSha512String hashes a string using sha512 and returns the results hex encoded

func NormalizeKey

func NormalizeKey(key []byte) []byte

NormalizeKey returns a fixed length key of 32 bytes

Types

type EncryptReader

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

EncryptReader decrypts files using the io.Reader

func NewEncryptReader

func NewEncryptReader(key []byte, source io.Reader) (*EncryptReader, error)

NewEncryptReader creates a new instance of the encrypt reader This can read from another reader where the data is encrypted using EncryptWriter

func (*EncryptReader) Read

func (r *EncryptReader) Read(p []byte) (n int, err error)

Read Implements io.Reader

type EncryptWriter

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

EncryptWriter encrypts files using the io.Writer interface and writes the output directly to another io.Writer This is handy to use when you want to encrypt a large amount of data

func NewEncryptWriter

func NewEncryptWriter(key []byte, dst io.Writer) (*EncryptWriter, error)

NewEncryptWriter creates a new instance of the encrypt writer

func (*EncryptWriter) Close

func (ew *EncryptWriter) Close() error

Close Implements io.Closer This writes the remaining data to the underlying writer

func (*EncryptWriter) Write

func (ew *EncryptWriter) Write(p []byte) (n int, err error)

Write Implements io.Writer

Jump to

Keyboard shortcuts

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