MCPcopy Create free account
hub / github.com/Driver-C/tryssh / TestEncryptDecrypt_RoundTrip

Function TestEncryptDecrypt_RoundTrip

pkg/utils/crypto_test.go:11–26  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

9)
10
11func TestEncryptDecrypt_RoundTrip(t *testing.T) {
12 key := make([]byte, 32)
13 for i := range key {
14 key[i] = byte(i)
15 }
16
17 plaintext := "my-secret-password"
18 encrypted, err := Encrypt(plaintext, key)
19 assert.NoError(t, err)
20 assert.NotEqual(t, plaintext, encrypted)
21 assert.True(t, IsEncrypted(encrypted))
22
23 decrypted, err := Decrypt(encrypted, key)
24 assert.NoError(t, err)
25 assert.Equal(t, plaintext, decrypted)
26}
27
28func TestEncryptDecrypt_EmptyString(t *testing.T) {
29 key := make([]byte, 32)

Callers

nothing calls this directly

Calls 3

EncryptFunction · 0.85
IsEncryptedFunction · 0.85
DecryptFunction · 0.85

Tested by

no test coverage detected