Пример #1
0
func main() {
	fmt.Printf("Test string: %q len(test): %d\n", test, len(test))
	fmt.Printf("Correct result: %q len(result): %d\n", result, len(result))

	base64 := mcc.Hex2base64(mcc.String2Hex(test))
	fmt.Printf("Our result: %s\n", base64)

	if cmp := bytes.Compare([]byte(result), base64); cmp != 0 {
		fmt.Println("Your code is wrong!")
	} else {
		fmt.Println("Your code is correct! :)")
	}
	return
}
Пример #2
0
func main() {
	hexCrypt := mcc.String2Hex(crypt)
	// Key has to be of type []byte, even if just one byte.
	key := []byte{0}

	for i := 0; i <= 255; i++ {
		key[0] = byte(i)
		decrypted := mcc.KeyXOR(key, []byte(hexCrypt))
		freq := mcc.SymbolFrequency(decrypted)
		if mcc.IsDistSimilarTo(freq, mcc.EnglishDist, 0.1, 16) {
			fmt.Printf("Key: %s\nCryptogram: %s\n", key, decrypted)
		}
	}
	return
}
Пример #3
0
func main() {
	stringFirst := mcc.String2Hex(first)
	stringSecond := mcc.String2Hex(second)
	stringResult := mcc.String2Hex(result)
	fmt.Printf("First byte stream: %q (%q)\n", first, stringFirst)
	fmt.Printf("Second byte stream: %q (%q)\n", second, stringSecond)
	fmt.Printf("Correct result: %q (%q)\n", result, stringResult)

	xor := mcc.ArrayXOR(mcc.String2Hex(first), mcc.String2Hex(second))
	stringXOR := mcc.Hex2String(xor)
	fmt.Printf("\nOur result: %q (%q)\n", stringXOR, xor)

	if cmp := bytes.Compare(xor, mcc.String2Hex(result)); cmp != 0 {
		fmt.Printf("Your code is wrong!\n")
	} else {
		fmt.Printf("Your code is correct! :)\n")
	}
	return
}