Skip to content

Instantly share code, notes, and snippets.

@felixbuenemann
Created September 5, 2020 21:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save felixbuenemann/eb634a9498fa4bdc6895f9e9dc10fe98 to your computer and use it in GitHub Desktop.
Save felixbuenemann/eb634a9498fa4bdc6895f9e9dc10fe98 to your computer and use it in GitHub Desktop.
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)
}
@felixbuenemann
Copy link
Author

offset:17960960 size:3010560	(expected: 3010560)	md5:8abd34cd100b270b824100ebafe6e3fb (expected: 8abd34cd100b270b824100ebafe6e3fb)
offset:20971520 size:10485760	(expected: 10485760)	md5:762310874c8716000eb81bb1834a8e62 (expected: 762310874c8716000eb81bb1834a8e62)
offset:31457280 size:3280896	(expected: 3280896)	md5:1008f316ca473e682ca5f64a648f6e46 (ecpected: 1008f316ca473e682ca5f64a648f6e46)
offset:17960960 size:16777216	(expected: 16777216)	md5:cd57a4d423b6631252cdabb758bbbc20 (expected: d598e19a67dce51538bd1cafd96ef872)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment