Md5 hashing function

I’m new at Golang and programming in general and this might be a little over my capabilities, but anyway.

I’m trying to implement a function that starting form a video file,
would return the md5 hash composed by taking the first and the last 64kb of the video file,
putting all together and generating a md5 of the resulting data (128kb).

I have put together with the help of Google the md5 hash function, what I am struggling to realize
is how to “take” the first and last 64Kb of the file and then “join” together these pieces.

On a Discord golang group I have been hinted to look at the Seek() function on the os package :

func main() {
testFile := os.Args[1]
var offset int64 = 64 * 1024 //64Kb
var whence int = 0           //starting from the beginning of the file
file, err := os.Open(testFile)
if err != nil {

newPosition, err := file.Seek(offset, whence)
if err != nil {

fmt.Println("Moved to new position: ", newPosition)

newPosition returns an int64, do I write to a new writer?

Thanks in advance

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.