mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-21 20:26:41 +00:00
Import bzzhash from bzz-fefe branch
This commit is contained in:
parent
927fcc7acf
commit
463b056518
1 changed files with 28 additions and 0 deletions
28
bzz/bzzhash/bzzhash.go
Normal file
28
bzz/bzzhash/bzzhash.go
Normal file
|
|
@ -0,0 +1,28 @@
|
||||||
|
// bzzhash
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"github.com/ethereum/go-ethereum/bzz"
|
||||||
|
"io"
|
||||||
|
"os"
|
||||||
|
)
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
|
||||||
|
if len(os.Args) < 2 {
|
||||||
|
fmt.Println("Usage: bzzhash <file name>")
|
||||||
|
os.Exit(0)
|
||||||
|
}
|
||||||
|
f, err := os.Open(os.Args[1])
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println("Error opening file " + os.Args[1])
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
|
||||||
|
stat, _ := f.Stat()
|
||||||
|
sr := io.NewSectionReader(f, 0, stat.Size())
|
||||||
|
hash := bzz.GetDPAhash(sr, nil)
|
||||||
|
|
||||||
|
fmt.Printf("%064x\n", hash)
|
||||||
|
}
|
||||||
Loading…
Reference in a new issue