Skip to content

Instantly share code, notes, and snippets.

@fd0

fd0/main.go Secret

Last active November 28, 2018 07:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fd0/a74e42a7a4f51c4ccaa6c11a09c14619 to your computer and use it in GitHub Desktop.
Save fd0/a74e42a7a4f51c4ccaa6c11a09c14619 to your computer and use it in GitHub Desktop.
package main
import (
"fmt"
"io"
"os"
"github.com/restic/chunker"
)
func main() {
p, err := chunker.RandomPolynomial()
if err != nil {
panic(err)
}
fmt.Printf("using polynomial %v for splitting data\n", p)
chk := chunker.New(os.Stdin, p)
buf := make([]byte, 16*1024*1024) // 16 MiB
for {
chunk, err := chk.Next(buf)
if err == io.EOF {
break
}
if err != nil {
panic(err)
}
fmt.Printf("%d\t%d\t%016x\n", chunk.Start, chunk.Length, chunk.Cut)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment