mirror of
https://github.com/celogeek/piwigo-cli.git
synced 2025-05-25 02:02:37 +02:00
25 lines
338 B
Go
25 lines
338 B
Go
package piwigotools
|
|
|
|
import (
|
|
"crypto/md5"
|
|
"fmt"
|
|
"io"
|
|
"os"
|
|
)
|
|
|
|
func Md5File(filename string) (result string, err error) {
|
|
file, err := os.Open(filename)
|
|
if err != nil {
|
|
return
|
|
}
|
|
defer file.Close()
|
|
|
|
hash := md5.New()
|
|
_, err = io.Copy(hash, file)
|
|
if err != nil {
|
|
return
|
|
}
|
|
result = fmt.Sprintf("%x", hash.Sum(nil))
|
|
return
|
|
}
|