mirror of
https://github.com/schollz/croc.git
synced 2025-10-11 13:21:00 +02:00
fix hash file
This commit is contained in:
parent
274fab92a1
commit
828f83601d
2 changed files with 6 additions and 3 deletions
|
@ -89,8 +89,9 @@ func receive(c *websocket.Conn, codephrase string) (err error) {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
// await file
|
// await file
|
||||||
f, err := os.Create("out")
|
f, err := os.Create(fstats.Name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
log.Error(err)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
bytesWritten := 0
|
bytesWritten := 0
|
||||||
|
@ -149,8 +150,9 @@ func receive(c *websocket.Conn, codephrase string) (err error) {
|
||||||
bar.Finish()
|
bar.Finish()
|
||||||
|
|
||||||
// check hash
|
// check hash
|
||||||
hash256, err := utils.HashFile("out")
|
hash256, err := utils.HashFile(fstats.Name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
log.Error(err)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,8 +6,9 @@ import (
|
||||||
"os"
|
"os"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// HashFile returns the md5 hash of a file
|
||||||
func HashFile(fname string) (hash256 []byte, err error) {
|
func HashFile(fname string) (hash256 []byte, err error) {
|
||||||
f, err := os.Open("file.txt")
|
f, err := os.Open(fname)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue