This page looks best with JavaScript enabled

Matasano Crypto Challenges - 1/2 - Solved in Go

· ☕ 1 min read

This is the solution I came up with in Go for Set 1 / Challenge 2 of the
matasano crypto challenges.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
package main

import hex "encoding/hex"
import "fmt"

func main() {

    source1 := "1c0111001f010100061a024b53535009181c"
    source2 := "686974207468652062756c6c277320657965"

    source1Hex, _ := hex.DecodeString(source1)
    source2Hex, _ := hex.DecodeString(source2)

    finalHex := make([]byte, 0)

    for i, b := range source1Hex {
        finalHex = append(finalHex, b^source2Hex[i])
    }

    finalHexString := hex.EncodeToString(finalHex)

    fmt.Println(finalHexString)
}

Running this will output the expected result, like so:

1
2
Pu:~ nate$ go run Set1Challenge2.go 
746865206b696420646f6e277420706c6179
Share on

Nathaniel Michael
WRITTEN BY
Nathaniel Michael
Engineer