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