diff options
-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 +} |