MCPcopy Create free account
hub / github.com/KOSASIH/skybridge / TestEncryption_EncryptDecrypt

Function TestEncryption_EncryptDecrypt

src/crypto/encryption/encryption_test.go:7–24  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

5)
6
7func TestEncryption_EncryptDecrypt(t *testing.T) {
8 encryption, err := NewEncryption("my_secret_key")
9 if err != nil {
10 t.Errorf("Expected NewEncryption to return a non-nil error")
11 }
12 plaintext := "Hello, World!"
13 ciphertext, err := encryption.Encrypt([]byte(plaintext))
14 if err != nil {
15 t.Errorf("Expected Encrypt to return a non-nil error")
16 }
17 decrypted, err := encryption.Decrypt(ciphertext)
18 if err != nil {
19 t.Errorf("Expected Decrypt to return a non-nil error")
20 }
21 if string(decrypted) != plaintext {
22 t.Errorf("Expected decrypted text to match original plaintext")
23 }
24}
25
26func TestEncryption_EncryptBase64DecryptBase64(t *testing.T) {
27 encryption, err := NewEncryption("my_secret_key")

Callers

nothing calls this directly

Calls 3

EncryptMethod · 0.95
DecryptMethod · 0.95
NewEncryptionFunction · 0.85

Tested by

no test coverage detected