From 4350ac9b1ed7f06a5f1e54e09d9414a06be9c184 Mon Sep 17 00:00:00 2001 From: Mike Date: Tue, 22 Oct 2024 15:40:03 -0700 Subject: [PATCH] fix: allows encryption with specified key --- pkg/security/encrypt.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/pkg/security/encrypt.go b/pkg/security/encrypt.go index 00a6d7fe..afb59d8d 100644 --- a/pkg/security/encrypt.go +++ b/pkg/security/encrypt.go @@ -10,7 +10,12 @@ import ( // Encrypt encrypts a string. func (c Crypto) Encrypt(plainText string) (string, error) { - block, err := aes.NewCipher([]byte(c.EncryptionKey)) + return c.EncryptWithKey(plainText, c.EncryptionKey) +} + +// Encrypt encrypts a string with provided key. +func (c Crypto) EncryptWithKey(plainText string, key string) (string, error) { + block, err := aes.NewCipher([]byte(key)) if err != nil { return "", err }