Refactor db init

This commit is contained in:
2024-11-23 22:33:55 +01:00
parent 9f241271a7
commit 9d81b1036d
4 changed files with 26 additions and 22 deletions

View File

@@ -10,8 +10,8 @@ import (
"io"
)
// Encryptor is an interface for encrypting and decrypting strings
type Encryptor interface {
// Service is an interface for encrypting and decrypting strings
type Service interface {
Encrypt(plaintext string) (string, error)
Decrypt(ciphertext string) (string, error)
}
@@ -51,8 +51,8 @@ func decodeAndValidateKey(key string) ([]byte, error) {
return keyBytes, nil
}
// New creates a new Crypto instance with the provided base64-encoded key
func New(key string) (Encryptor, error) {
// NewService creates a new Encryptor instance with the provided base64-encoded key
func NewService(key string) (Service, error) {
keyBytes, err := decodeAndValidateKey(key)
if err != nil {
return nil, err