github.com/safedep/dry@v0.0.0-20241016050132-a15651f0548b/crypto/aes_test.go (about) 1 package crypto 2 3 import ( 4 "testing" 5 6 "github.com/stretchr/testify/assert" 7 ) 8 9 func TestAesEncryptDecrypt(t *testing.T) { 10 salt := "saltsalt" 11 key := "keykeykeykey" 12 13 encryptor, err := NewAesEncryptor(salt, key) 14 assert.NoError(t, err) 15 16 data := []byte("hello world") 17 encrypted, err := encryptor.Encrypt(data) 18 assert.NoError(t, err) 19 20 assert.NotEqual(t, data, encrypted) 21 22 decrypted, err := encryptor.Decrypt(encrypted) 23 assert.NoError(t, err) 24 25 assert.Equal(t, data, decrypted) 26 }