28 lines
1.1 KiB
Go
28 lines
1.1 KiB
Go
package go_encryption
|
|
|
|
type IEncryptionProvider interface {
|
|
// SetEncryptionKey allows to modify the encryption key.
|
|
SetEncryptionKey(key []byte)
|
|
|
|
// SetContext allows to modify the encryption context.
|
|
SetContext(context []byte) (err error)
|
|
|
|
// Encrypt tries to encrypt the given binary with the appropriate cipher.
|
|
Encrypt(binary []byte) (encrypted []byte, err error)
|
|
|
|
// EncryptData returns the given data as JSON in encrypted form.
|
|
EncryptData(data interface{}) (encrypted []byte, err error)
|
|
|
|
// EncryptToFile saves the given data to the given filepath as JSON in encrypted form.
|
|
EncryptToFile(data interface{}, filepath string) (err error)
|
|
|
|
// Decrypt tries to decrypt the given binary with the appropriate cipher.
|
|
Decrypt(binary []byte) (decrypted []byte, err error)
|
|
|
|
// DecryptData tries to decrypt the given binary and to unmarshal the resulting JSON to the target interface.
|
|
DecryptData(binary []byte, target interface{}) (err error)
|
|
|
|
// DecryptData tries to decrypt the content of the file specified and to unmarshal the resulting JSON to the target interface.
|
|
DecryptFile(path string, target interface{}) (err error)
|
|
}
|