Documentation
¶
Overview ¶
Package sym is a simple and lightweight symmetric encryption/decryption pkg.
Index ¶
- Variables
- func DecryptBytes(key string, ciphertextBytes []byte) ([]byte, error)
- func DecryptDir(key, src, dest string) error
- func DecryptFile(key, in, out string) error
- func DecryptString(key, ciphertext string) (string, error)
- func EncryptBytes(key string, plaintextBytes []byte) ([]byte, error)
- func EncryptDir(key, src, dest string) error
- func EncryptFile(key, in, out string) error
- func EncryptString(key, plaintext string) (string, error)
- func IsEncryptedDir(key, src string) bool
- func KeyFromFilePath(path string) (string, error)
- func KeyGen(size int) (string, error)
- func MustKeyGen() string
Constants ¶
This section is empty.
Variables ¶
var ErrEmptyPayload = errors.New("empty payload")
ErrEmptyPayload is returned when the ciphertext string or bytes provided for an encrypt/decrypt operation are empty or nil.
var ErrInvalidIvLen = errors.New("cipher text does not contain a valid initialization vector length")
ErrInvalidIvLen is returned when the provided ciphertext for a decrypt operation is not at least the length of a valid initialization vector.
var ErrNotDir = errors.New("not a directory")
Functions ¶
func DecryptBytes ¶
DecryptBytes uses key to return the decrypted content of ciphertextBytes.
func DecryptDir ¶ added in v1.3.0
DecryptDir uses key to decrypt src into a zip file. The zip file is then unzipped into dest.
func DecryptFile ¶
DecryptFile opens in and uses key to decrypt it's ciphertext contents; writing the plaintext contents to out.
func DecryptString ¶
DecryptString uses key to return the decrypted string contents of ciphertext.
func EncryptBytes ¶
EncryptBytes uses key to encrypt plaintextBytes; returning the ciphertext bytes.
func EncryptDir ¶ added in v1.3.0
EncryptDir zips the dir at src and encrypts the zip file with key.
func EncryptFile ¶
EncryptFile opens in and uses key to encrypt it's plaintext contents; writing the ciphertext contents to out.
func EncryptString ¶
EncryptString uses key to encrypt plaintext; returning the ciphertext string.
func IsEncryptedDir ¶ added in v1.3.0
IsEncryptedDir decrypts src using key and checks if it's a zip file.
func KeyFromFilePath ¶ added in v1.1.0
KeyFromFile reads the file at path, validates the key, and then returns it. If the file does not exist a non-nil error is returned. If the file exists and the key is invalid a non-nil error is returned.
func KeyGen ¶ added in v1.1.0
KeyGen generates a new key that can be used to encrypt/decrypt strings, byte-data, and files. If size is not 16, 32, or 32 a non-nil error will be returned.
func MustKeyGen ¶ added in v1.1.0
func MustKeyGen() string
MustKeyGen always generates a size 16 key.
Types ¶
This section is empty.