Esempio n. 1
0
func TestSeekXorFromFile(t *testing.T) {
	filename := "./source_4"
	candidates := SeekXorInFile(filename)
	for i := 0; i < 5; i++ {
		t.Logf("res %q\n", candidates[i])
	}
	assert.AssertEquals(t, string(candidates[0].Decrypted), "Now that the party is jumping\n")
}
Esempio n. 2
0
func TestSeekXor(t *testing.T) {
	src := hexa.HexaToBytes("1b37373331363f78151b7f2b783431333d78397828372d363c78373e783a393b3736")
	candidates := SeekXor(src)
	for i := 0; i < 5; i++ {
		t.Logf("Candidate %d is %q\n", candidates[i])
	}
	assert.AssertEquals(t, string(candidates[0].Decrypted), "Cooking MC's like a pound of bacon")
}
Esempio n. 3
0
func TestBase64Decode(t *testing.T) {
	src := "SSdtIGtpbGxpbmcgeW91ciBicmFpbiBsaWtlIGEgcG9pc29ub3VzIG11c2hyb29t"
	assert.AssertEquals(t, Base64ToString(StringToBase64(src)), src)
}
Esempio n. 4
0
func TestBase64Encode(t *testing.T) {
	src := hexa.HexaToBytes("49276d206b696c6c696e6720796f757220627261696e206c696b65206120706f69736f6e6f7573206d757368726f6f6d")
	expected := "SSdtIGtpbGxpbmcgeW91ciBicmFpbiBsaWtlIGEgcG9pc29ub3VzIG11c2hyb29t"
	assert.AssertEquals(t, Base64ToString(Base64Encode(src)), expected)
}
Esempio n. 5
0
func TestSimpleBase64(t *testing.T) {
	src := []byte("Man")
	expected := "TWFu"
	assert.AssertEquals(t, Base64ToString(Base64Encode(src)), expected)
}
Esempio n. 6
0
func TestHexa(t *testing.T) {
	assert.AssertEquals(t, HexaToString([]byte{0x0f}), "0f")
	assert.AssertEquals(t, HexaToString([]byte{0x0f, 0xac}), "0fac")
}
Esempio n. 7
0
func TestDistance(t *testing.T) {
	first := []byte("this is a test")
	snd := []byte("wokka wokka!!!")
	assert.AssertEquals(t, HammingDistance(first, snd), 37)
}
Esempio n. 8
0
func TestRepeatedXor(t *testing.T) {
	xor := "ICE"
	res := Xor([]byte(testText), []byte(xor))
	expected := "0b3637272a2b2e63622c2e69692a23693a2a3c6324202d623d63343c2a26226324272765272a282b2f20430a652e2c652a3124333a653e2b2027630c692b20283165286326302e27282f"
	assert.AssertEquals(t, hexa.HexaToString(res), expected)
}