diff options
| author | Ophestra <cat@gensokyo.uk> | 2026-04-13 03:09:21 +0900 |
|---|---|---|
| committer | Ophestra <cat@gensokyo.uk> | 2026-04-13 03:09:21 +0900 |
| commit | 86eacb32089d1e3f335e82b7c073a40c13b116d2 (patch) | |
| tree | 6b226ff0dc354e7600d743cdafafc95c35eb129d /cmd | |
| parent | 8541bdd8586f050afd9e7713bb68267c54a9e67c (diff) | |
cmd/mbf: checksum command
This computes and encodes sha384 checksum of data streamed from standard input.
Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'cmd')
| -rw-r--r-- | cmd/mbf/main.go | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/cmd/mbf/main.go b/cmd/mbf/main.go index 41735646..74b1bd7f 100644 --- a/cmd/mbf/main.go +++ b/cmd/mbf/main.go @@ -14,6 +14,7 @@ package main import ( "context" + "crypto/sha512" "errors" "fmt" "io" @@ -126,6 +127,19 @@ func main() { "abstract UNIX sockets", ) + c.NewCommand( + "checksum", "Compute checksum of data read from standard input", + func([]string) error { + go func() { <-ctx.Done(); os.Exit(1) }() + h := sha512.New384() + if _, err := io.Copy(h, os.Stdin); err != nil { + return err + } + log.Println(pkg.Encode(pkg.Checksum(h.Sum(nil)))) + return nil + }, + ) + { var flagShifts int c.NewCommand( |
