FNV hash
This commit is contained in:
parent
46da91f833
commit
69c7da0c88
1
.gitignore
vendored
1
.gitignore
vendored
@ -34,3 +34,4 @@ upper-words/upper-words
|
||||
longest-word/longest-word
|
||||
statecsv/statecsv
|
||||
go-financial/go-financial
|
||||
my-fnv/my-fnv
|
||||
|
23
my-fnv/main.go
Normal file
23
my-fnv/main.go
Normal file
@ -0,0 +1,23 @@
|
||||
package main
|
||||
|
||||
import "fmt"
|
||||
import "hash/fnv"
|
||||
import "io"
|
||||
import "log"
|
||||
import "os"
|
||||
|
||||
func main() {
|
||||
if len(os.Args) < 2 {
|
||||
log.Fatalln("Usage my-fmv file")
|
||||
}
|
||||
f, err := os.Open(os.Args[1])
|
||||
if err != nil {
|
||||
log.Fatalln(err)
|
||||
}
|
||||
defer f.Close()
|
||||
|
||||
h := fnv.New64()
|
||||
|
||||
io.Copy(h, f)
|
||||
fmt.Printf("%x\n", h.Sum64())
|
||||
}
|
Loading…
Reference in New Issue
Block a user