Skip to content

Commit

Permalink
Add: add get flie md5 hash support
Browse files Browse the repository at this point in the history
  • Loading branch information
vcaesar committed Oct 6, 2024
1 parent a6c80ca commit 6f8d1d8
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion file/sys.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"io"
"os"

"crypto/md5"
"crypto/sha1"
"crypto/sha256"
"path/filepath"
Expand Down Expand Up @@ -104,7 +105,11 @@ func Sha(filePath string, args ...string) (sha string, err error) {
func IoSha(fileIO *os.File, args ...string) (string, error) {
h := sha1.New()
if len(args) > 0 {
h = sha256.New()
if args[0] == "md5" {
h = md5.New()
} else {
h = sha256.New()
}
}

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

0 comments on commit 6f8d1d8

Please sign in to comment.