Created
September 5, 2020 21:02
This file contains hidden or 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 ( | |
"crypto/md5" | |
"fmt" | |
"os" | |
) | |
func check(e error) { | |
if e != nil { | |
panic(e) | |
} | |
} | |
func main() { | |
f, err := os.Open("testorig.mkv") | |
check(err) | |
_, err = f.Seek(17960960, 0) | |
check(err) | |
b1 := make([]byte, 3010560) | |
n1, err := f.Read(b1) | |
check(err) | |
m1 := md5.Sum(b1) | |
fmt.Printf("offset:17960960 size:%v\t(expected: 3010560)\tmd5:%x (expected: 8abd34cd100b270b824100ebafe6e3fb)\n", n1, m1) | |
b2 := make([]byte, 10485760) | |
n2, err := f.Read(b2) | |
check(err) | |
m2 := md5.Sum(b2) | |
fmt.Printf("offset:20971520 size:%v\t(expected: 10485760)\tmd5:%x (expected: 762310874c8716000eb81bb1834a8e62)\n", n2, m2) | |
b3 := make([]byte, 3280896) | |
n3, err := f.Read(b3) | |
m3 := md5.Sum(b3) | |
check(err) | |
fmt.Printf("offset:31457280 size:%v\t(expected: 3280896)\tmd5:%x (ecpected: 1008f316ca473e682ca5f64a648f6e46)\n", n3, m3) | |
b := make([]byte, 16777216) | |
n := 0 | |
n += copy(b[0:], b1) | |
n += copy(b[3010560:], b2) | |
n += copy(b[10485760:], b3) | |
m := md5.Sum(b) | |
fmt.Printf("offset:17960960 size:%v\t(expected: 16777216)\tmd5:%x (expected: d598e19a67dce51538bd1cafd96ef872)\n", n, m) | |
} |
Author
felixbuenemann
commented
Sep 5, 2020
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment