xorenc/xorencrypt_test.go

30 lines
592 B
Go
Raw Permalink Normal View History

2021-11-24 16:25:28 +00:00
package xorenc
2021-11-17 01:44:15 +00:00
import (
"fmt"
"testing"
)
func TestXOR(t *testing.T) {
msg := "test"
key := "key"
enc := xor([]byte(msg), []byte(key))
dec := xor([]byte(enc), []byte(key))
fmt.Printf("%s -> %d -> %s\n", msg, enc, dec)
}
func TestEncrypt(t *testing.T) {
msg := "test"
key := "key"
enc := Encrypt(msg, key)
dec, _ := Decrypt(enc, key)
fmt.Printf("%s -> %s -> %s\n", msg, enc, dec)
decErr, _ := Decrypt(enc, "wrongKey")
fmt.Printf("%s -> %s -> %s\n", msg, enc, decErr)
2021-11-17 01:50:25 +00:00
encD := Encrypt(msg, "")
decD, _ := Decrypt(encD, "")
fmt.Printf("%s -> %s -> %s\n", msg, encD, decD)
2021-11-17 01:44:15 +00:00
}