This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func hexToBinary(hexnum string) string { | |
if hexnum == "0" { | |
return "0000" | |
} else if hexnum == "1" { | |
return "0001" | |
} else if hexnum == "2" { | |
return "0010" | |
} else if hexnum == "3" { | |
return "0011" | |
} else if hexnum == "4" { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func distanceBetweenChunks(keysize int, data string) float64 { | |
// we are using hex string here as input : one ascii char is two hex digits long | |
out := 0.0 | |
totalNumberOfChunks := 0.0 | |
for i := 0; i < len(data)/(5*keysize); i++ { | |
offset := i * 4 * keysize | |
firstChunk := data[offset : offset+keysize*2] | |
secondChunk := data[offset+keysize*2 : offset+4*keysize] | |
res := float64(hamming(firstChunk, secondChunk)) | |
res /= float64(keysize) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func ReadFile(filename string) []byte { | |
file, err := os.Open(filename) | |
if err != nil { | |
log.Fatal(err) | |
} | |
scan := bufio.NewScanner(file) | |
bytes := make([]byte, 0, 1024) | |
for scan.Scan() { | |
input := []byte(scan.Text()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func countDuplicates(elem [10][]byte) int { | |
tmp := elem | |
ret := 0 | |
for i := range tmp { | |
for j := range elem { | |
if i != j && reflect.DeepEqual(tmp[i], elem[j]) { | |
ret++ | |
} | |
} | |
} |
OlderNewer