Exemplo n.º 1
0
func main() {
	demo0 := "Burning 'em, if you ain't quick and nimble\nI go crazy when I hear a cymbal"

	success0 := "0b3637272a2b2e63622c2e69692a23693a2a3c6324202d623d63343c2a26226324272765272a282b2f20430a652e2c652a3124333a653e2b2027630c692b20283165286326302e27282f"

	output0, err := libcryptopals.StringRepeatingXor(demo0, "ICE")
	if err != nil {
		fmt.Println("Error in XOR process ", err)
		return
	}
	successBytes, err := libcryptopals.Hex2Byte(success0)
	if err != nil {
		fmt.Println("Couldn't decode success0")
		return
	}
	output1, err := libcryptopals.SliceRepeatingXor(successBytes, []byte("ICE"))
	if err != nil {
		fmt.Println("Error in XOR process ", err)
		return
	}

	fmt.Println("First line succeeded:", output0 == success0)
	fmt.Println("Output0: ", output0)
	fmt.Println("len(Output0): ", len(output0), " len(dem0): ", len(demo0), " len(success0): ", len(success0))
	fmt.Println("& reverse: ", string(output1))
	fmt.Println("& reverse == success0 ", demo0 == string(output1))
}
Exemplo n.º 2
0
func main() {
	var key *string = flag.String("key", "foo", "key to encrypt with")
	var text *string = flag.String("text", "barbazbang", "text to encipher")
	var score *bool = flag.Bool("score", false, "just print out score of text block")
	flag.Parse()

	if *score {
		fmt.Println("Score of blob is ", libcryptopals.EScore([]byte(*text)))
		return
	}
	fmt.Println(*key)
	fmt.Println(*text)
	outhex, err := libcryptopals.StringRepeatingXor(*text, *key)
	if err != nil {
		fmt.Println(err)
		return
	}
	outbytes, err := libcryptopals.Hex2Byte(outhex)
	if err != nil {
		fmt.Println(err)
		return
	}
	fmt.Printf("Base64 encrypted text:\n%s\n", libcryptopals.Byte2Base64(outbytes))
	fmt.Println(libcryptopals.DecodeXorEncodedBlock(outbytes))
}
Exemplo n.º 3
0
func main() {
	fmt.Println("go")
	a := "1c0111001f010100061a024b53535009181c"
	b := "686974207468652062756c6c277320657965"
	abyte, _ := libcryptopals.Hex2Byte(a)
	bbyte, _ := libcryptopals.Hex2Byte(b)
	final, _ := libcryptopals.SliceXor(abyte, bbyte)
	desired, _ := libcryptopals.Hex2Byte("746865206b696420646f6e277420706c6179")

	if len(final) != len(desired) {
		fmt.Println("!!! lengths don't match")
	}
	for i, _ := range final {
		if final[i] != desired[i] {
			fmt.Println("output incorrect at offset ", i)
			return
		}
	}
	fmt.Println("A-OK everything works")
}