copy the other repo and make packages install.
This commit is contained in:
26
commands.go
Normal file
26
commands.go
Normal file
@@ -0,0 +1,26 @@
|
||||
package opentimestamps
|
||||
|
||||
import (
|
||||
"crypto/sha256"
|
||||
"io"
|
||||
"os"
|
||||
)
|
||||
|
||||
func CreateDetachedTimestampForFile(
|
||||
path string, cal *RemoteCalendar,
|
||||
) (*DetachedTimestamp, error) {
|
||||
f, err := os.Open(path)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
hasher := sha256.New()
|
||||
if _, err := io.Copy(hasher, f); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
digest := hasher.Sum([]byte{})
|
||||
ts, err := cal.Submit(digest)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return NewDetachedTimestamp(*opSHA256, digest, ts)
|
||||
}
|
||||
Reference in New Issue
Block a user