mirror of
https://github.com/KyleBanks/XOREncryption.git
synced 2023-08-10 21:13:15 +03:00
23 lines
603 B
Go
23 lines
603 B
Go
package xor
|
|
|
|
import "testing"
|
|
|
|
func TestEncryptDecrypt(t *testing.T) {
|
|
sample := "kylewbanks.com"
|
|
key := "KCQ"
|
|
|
|
// Test encrypting
|
|
encrypted := EncryptDecrypt(sample, key)
|
|
if encrypted == sample {
|
|
t.Fatalf("Expected encrypted string not to match the input: %v", encrypted)
|
|
} else if len(encrypted) != len(sample) {
|
|
t.Fatalf("Expected encrypted string to have the same length as the input: %v", len(encrypted))
|
|
}
|
|
|
|
// Test decrypting
|
|
decrypted := EncryptDecrypt(encrypted, key)
|
|
if decrypted != sample {
|
|
t.Fatalf("Expected decrypted string to match the original input: %v", decrypted)
|
|
}
|
|
}
|