Convert global encryption functions into vars

This commit is contained in:
Tania B 2021-10-27 16:10:49 +03:00
parent efad575443
commit 498eb19859
No known key found for this signature in database
GPG Key ID: CF124EC865EEC604

View File

@ -17,7 +17,7 @@ const saltLength = 8
// Decrypt decrypts a payload with a given secret.
// DEPRECATED. Do not use it.
// Use secrets.Service instead.
func Decrypt(payload []byte, secret string) ([]byte, error) {
var Decrypt = func(payload []byte, secret string) ([]byte, error) {
if len(payload) < saltLength {
return nil, fmt.Errorf("unable to compute salt")
}
@ -51,7 +51,7 @@ func Decrypt(payload []byte, secret string) ([]byte, error) {
// Encrypt encrypts a payload with a given secret.
// DEPRECATED. Do not use it.
// Use secrets.Service instead.
func Encrypt(payload []byte, secret string) ([]byte, error) {
var Encrypt = func(payload []byte, secret string) ([]byte, error) {
salt, err := GetRandomString(saltLength)
if err != nil {
return nil, err