cmd/mbf: checksum command
All checks were successful
Test / Create distribution (push) Successful in 1m19s
Test / Sandbox (push) Successful in 3m16s
Test / Hakurei (push) Successful in 4m36s
Test / ShareFS (push) Successful in 4m43s
Test / Sandbox (race detector) (push) Successful in 5m55s
Test / Hakurei (race detector) (push) Successful in 7m11s
Test / Flake checks (push) Successful in 1m31s

This computes and encodes sha384 checksum of data streamed from standard input.

Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
2026-04-13 03:09:21 +09:00
parent 8541bdd858
commit 86eacb3208

View File

@@ -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(