Exemple #1
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))
}
Exemple #2
0
func main() {
	var path *string = flag.String("target", "src/set1/challenge6/6.txt", "path to b64 encoded & encrypted file")
	flag.Parse()
	fmt.Println("Path: ", *path)
	input, err := SlurpB64EncodedFile(*path)
	if err != nil {
		panic(err)
	}

	fmt.Println(string(libcryptopals.DecodeXorEncodedBlock(input)))
}