Skip to content

Commit d4ff471

Browse files
authored
Merge pull request #20 from go-vgo/utf-pr
Add: add get flie md5 hash support
2 parents b0b4d56 + 6f8d1d8 commit d4ff471

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

file/sys.go

+6-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"io"
77
"os"
88

9+
"crypto/md5"
910
"crypto/sha1"
1011
"crypto/sha256"
1112
"path/filepath"
@@ -104,7 +105,11 @@ func Sha(filePath string, args ...string) (sha string, err error) {
104105
func IoSha(fileIO *os.File, args ...string) (string, error) {
105106
h := sha1.New()
106107
if len(args) > 0 {
107-
h = sha256.New()
108+
if args[0] == "md5" {
109+
h = md5.New()
110+
} else {
111+
h = sha256.New()
112+
}
108113
}
109114

110115
_, err := io.Copy(h, fileIO)

0 commit comments

Comments
 (0)