From 86eacb32089d1e3f335e82b7c073a40c13b116d2 Mon Sep 17 00:00:00 2001 From: Ophestra Date: Mon, 13 Apr 2026 03:09:21 +0900 Subject: [PATCH] cmd/mbf: checksum command This computes and encodes sha384 checksum of data streamed from standard input. Signed-off-by: Ophestra --- cmd/mbf/main.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) 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(