add zip and parity stuff
This commit is contained in:
23
fileUtilities/hash.go
Normal file
23
fileUtilities/hash.go
Normal file
@ -0,0 +1,23 @@
|
||||
package fileUtilities
|
||||
|
||||
import (
|
||||
"crypto/sha256"
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
)
|
||||
|
||||
func HashFile(filePath string) ([]byte, error) {
|
||||
file, err := os.Open(filePath)
|
||||
if err != nil {
|
||||
return []byte{}, fmt.Errorf("error opening file for hashing: %w", err)
|
||||
}
|
||||
defer file.Close()
|
||||
|
||||
h := sha256.New()
|
||||
if _, err := io.Copy(h, file); err != nil {
|
||||
return []byte{}, fmt.Errorf("error hashing file: %w", err)
|
||||
}
|
||||
|
||||
return h.Sum(nil), nil
|
||||
}
|
Reference in New Issue
Block a user