package utils

import (
	. "github.com/onsi/ginkgo/v2"
	. "github.com/onsi/gomega"
)

var _ = Describe("EncryptDecrypt", func() {
	type Req struct {
		Salt string
		Text string
	}
	var passphrase = "this_is_secret_key_in_env"

	It("should Encrypt/Decrypt successfully", func() {
		requests := []Req{
			{
				Salt: "salt_1_in_db",
				Text: "text 1",
			},
			{
				Salt: "salt_2_in_db",
				Text: "text 2",
			},
		}

		for _, v := range requests {
			res := Encrypt(passphrase, v.Text, []byte(v.Salt))
			decryptRes := Decrypt(passphrase, res, []byte(v.Salt))
			Expect(decryptRes).To(Equal(v.Text))
		}
	})
})
