Skip to content

Instantly share code, notes, and snippets.

@steveh
Created October 6, 2011 19:58
Show Gist options
  • Select an option

  • Save steveh/1268478 to your computer and use it in GitHub Desktop.

Select an option

Save steveh/1268478 to your computer and use it in GitHub Desktop.
package main
import (
"hash/crc32"
"fmt"
"os"
)
func main() {
table := crc32.MakeTable(crc32.Castagnoli)
hash := crc32.New(table)
path := "/Users/steve/Downloads/Trine_Setup_109.zip"
file, err := os.Open(path)
if (err != nil) {
return
}
bufLen := 1048576
buf := make([]byte, bufLen)
n, err := file.Read(buf)
for err == nil {
hash.Write(buf[0:n])
n, err = file.Read(buf)
}
err = file.Close()
var checksum = hash.Sum()
fmt.Printf("%s: %x\n", path, checksum)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment