diff options
author | Rasmus Dahlberg <rasmus@mullvad.net> | 2022-04-13 16:31:23 +0200 |
---|---|---|
committer | Rasmus Dahlberg <rasmus@mullvad.net> | 2022-04-13 16:31:23 +0200 |
commit | 10317e6bcbd391c80c573816d5d16c989f75a899 (patch) | |
tree | 18df9b775592ba15c7acd86805afb91a8fe57a6b /internal/util | |
parent | 8fee6561fbc21bd44f67dff9f365aa14da293d99 (diff) |
add hash file
Diffstat (limited to 'internal/util')
-rw-r--r-- | internal/util/crypto.go | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/internal/util/crypto.go b/internal/util/crypto.go index 2a29628..a8c8fac 100644 --- a/internal/util/crypto.go +++ b/internal/util/crypto.go @@ -4,8 +4,10 @@ import ( "crypto" "crypto/ed25519" "fmt" + "io/ioutil" "git.sigsum.org/sigsum-go/pkg/hex" + "git.sigsum.org/sigsum-go/pkg/types" ) func SignerFromHex(s string) (crypto.Signer, error) { @@ -18,3 +20,11 @@ func SignerFromHex(s string) (crypto.Signer, error) { } return ed25519.PrivateKey(b), nil } + +func FileHash(path string) (*types.Hash, error) { + b, err := ioutil.ReadFile(path) + if err != nil { + return nil, fmt.Errorf("util: read file %s: %v", path, err) + } + return types.HashFn(b), nil +} |