Instantly share code, notes, and snippets.

@fd0 /main.go Secret
Last active Nov 28, 2018

Embed
What would you like to do?
package main
import (
"crypto/sha256"
"fmt"
"io"
"os"
"github.com/restic/chunker"
)
func main() {
chk := chunker.New(os.Stdin, 0x3dea92648f6e83)
buf := make([]byte, 16*1024*1024) // 16 MiB
for {
chunk, err := chk.Next(buf)
if err == io.EOF {
break
}
if err != nil {
panic(err)
}
hash := sha256.Sum256(chunk.Data)
fmt.Printf("%d\t%d\t%016x\t%032x\n", chunk.Start, chunk.Length, chunk.Cut, hash)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment