21 lines
352 B
Go
21 lines
352 B
Go
package task
|
|
|
|
import (
|
|
"crypto/md5"
|
|
"fmt"
|
|
"io"
|
|
"os"
|
|
)
|
|
|
|
func hashFile(path string) ([]byte, error) {
|
|
file, err := os.Open(path)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("Opening File: %w", err)
|
|
}
|
|
|
|
hash := md5.New()
|
|
if _, err := io.Copy(hash, file); err != nil {
|
|
return nil, fmt.Errorf("Reading File: %w", err)
|
|
}
|
|
return hash.Sum(nil), nil
|
|
}
|