Created
January 5, 2018 05:56
-
-
Save liangchaoboy/a72bbddbf7300387dc379be5cc415d31 to your computer and use it in GitHub Desktop.
md5_mismatch_contrast
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
package main | |
import ( | |
"fmt" | |
"io/ioutil" | |
"log" | |
"os" | |
) | |
func main() { | |
a, err := ioutil.ReadFile(os.Args[1]) | |
if err != nil { | |
log.Panic(err) | |
} | |
b, err := ioutil.ReadFile(os.Args[2]) | |
if err != nil { | |
log.Panic(err) | |
} | |
var same = true | |
var last = 0 | |
for i := 0; i < len(a); i++ { | |
if (a[i] == b[i]) != same || i == len(a)-1 { | |
fmt.Printf("same:%v\tfrom: %v\tto: %v\tlen: %v\n", same, last, i-1, i-last) | |
same = !same | |
last = i | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment