Пример #1
0
func Test5(t *testing.T) {
	ciphertext, err := repeatingxor.Crypt([]byte(input5), []byte(key5))
	if err != nil {
		t.Error("Crypt returned error:", err)
	}

	result := encoding.EncodeHex(ciphertext)
	if string(result) != output5 {
		t.Error(string(result), "!=", output5)
	}
}
Пример #2
0
func Test2(t *testing.T) {
	raw1, err := encoding.DecodeHex([]byte(input2a))
	if err != nil {
		t.Error("Decoding", input2a, "failed")
	}

	raw2, err := encoding.DecodeHex([]byte(input2b))
	if err != nil {
		t.Error("Decoding", input2b, "failed")
	}

	result, err := bits.Xor(raw1, raw2)
	if err != nil {

	}

	resultEncoded := encoding.EncodeHex(result)
	if string(resultEncoded) != output2 {
		t.Error(string(resultEncoded), "!=", output2)
	}
}