Documentation ¶
Overview ¶
Package encrypt provides a collection of functions for safe encryption and decryption of data between different systems, such as databases, queues, and caches.
Index ¶
- func ByteDecryptAny(key, msg []byte, data any) error
- func ByteDecryptSerializeAny(key, msg []byte, data any) error
- func ByteEncryptAny(key []byte, data any) ([]byte, error)
- func ByteEncryptSerializeAny(key []byte, data any) ([]byte, error)
- func Decrypt(key, msg []byte) ([]byte, error)
- func DecryptAny(key []byte, msg string, data any) error
- func DecryptSerializeAny(key []byte, msg string, data any) error
- func Encrypt(key, msg []byte) ([]byte, error)
- func EncryptAny(key []byte, data any) (string, error)
- func EncryptSerializeAny(key []byte, data any) (string, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ByteDecryptAny ¶
ByteDecryptAny decrypts a byte-slice message produced with the ByteEncryptAny function to the provided data object. The value underlying data must be a pointer to the correct type for the next data item received. The key argument must be the same used to encrypt the data: either 16, 24, or 32 bytes to select AES-128, AES-192, or AES-256.
func ByteDecryptSerializeAny ¶
ByteDecryptSerializeAny decrypts a byte-slice message produced with the ByteEncryptSerializeAny function to the provided data object. The value underlying data must be a pointer to the correct type for the next data item received. The key argument must be the same used to encrypt the data: either 16, 24, or 32 bytes to select AES-128, AES-192, or AES-256.
func ByteEncryptAny ¶
ByteEncryptAny encrypts the input data with the specified key and returns a base64 byte slice. The input data is serialized using gob, encrypted with the Encrypt method and encoded as base64. The key argument must be either 16, 24, or 32 bytes to select AES-128, AES-192, or AES-256.
func ByteEncryptSerializeAny ¶
ByteEncryptSerializeAny encrypts the input data with the specified key and returns a base64 byte slice. The input data is serialized using json, encrypted with the Encrypt method and encoded as base64. The key argument must be either 16, 24, or 32 bytes to select AES-128, AES-192, or AES-256.
func Decrypt ¶
Decrypt decrypts a byte-slice data encrypted with the Encrypt function. The key argument must be the same used to encrypt the data: either 16, 24, or 32 bytes to select AES-128, AES-192, or AES-256.
func DecryptAny ¶
DecryptAny wraps the ByteDecryptAny function to accept a msg string instead of a byte slice.
func DecryptSerializeAny ¶
DecryptSerializeAny wraps the ByteDecryptSerializeAny function to accept a msg string instead of a byte slice.
func Encrypt ¶
Encrypt encrypts the byte-slice input msg with the specified key. The key argument must be either 16, 24, or 32 bytes to select AES-128, AES-192, or AES-256.
func EncryptAny ¶
EncryptAny wraps the ByteEncryptAny function to return a string instead of a byte slice.
Types ¶
This section is empty.