2024-10-28 00:05:33 +02:00
|
|
|
package cryptopals_test
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"mvvasilev.dev/cryptopals/set1"
|
|
|
|
)
|
|
|
|
|
|
|
|
const Challenge1HexValue = "49276d206b696c6c696e6720796f757220627261696e206c696b65206120706f69736f6e6f7573206d757368726f6f6d"
|
|
|
|
|
|
|
|
func Test_Challenge1(t *testing.T) {
|
|
|
|
const expected = "SSdtIGtpbGxpbmcgeW91ciBicmFpbiBsaWtlIGEgcG9pc29ub3VzIG11c2hyb29t"
|
|
|
|
|
|
|
|
value, success := set1.HexToBase64(Challenge1HexValue)
|
|
|
|
|
|
|
|
if !success || value != expected {
|
|
|
|
t.Fatal("Set 1, Challenge 1 has failed")
|
|
|
|
}
|
|
|
|
}
|
2024-10-28 17:54:51 +02:00
|
|
|
|
|
|
|
func Test_Challenge2(t *testing.T) {
|
|
|
|
const expected = "746865206b696420646f6e277420706c6179"
|
|
|
|
|
|
|
|
const content = "1c0111001f010100061a024b53535009181c"
|
|
|
|
const password = "686974207468652062756c6c277320657965"
|
|
|
|
|
|
|
|
value := set1.XORHexString(content, password)
|
|
|
|
|
|
|
|
if value != expected {
|
|
|
|
t.Fatal(("Set 1, Challenge 2 has failed"))
|
|
|
|
}
|
|
|
|
}
|