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

Function TestEncryptDecrypt_LongPlaintext

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

Source from the content-addressed store, hash-verified

217}
218
219func TestEncryptDecrypt_LongPlaintext(t *testing.T) {
220 key := make([]byte, 32)
221 for i := range key {
222 key[i] = byte(i)
223 }
224
225 // Generate a long plaintext (> 1KB)
226 longText := ""
227 for i := 0; i < 2000; i++ {
228 longText += "a"
229 }
230
231 encrypted, err := Encrypt(longText, key)
232 require.NoError(t, err)
233
234 decrypted, err := Decrypt(encrypted, key)
235 require.NoError(t, err)
236 assert.Equal(t, longText, decrypted)
237}
238
239func TestEncrypt_InvalidKey(t *testing.T) {
240 // AES requires 16, 24, or 32 byte keys

Callers

nothing calls this directly

Calls 2

EncryptFunction · 0.85
DecryptFunction · 0.85

Tested by

no test coverage detected