-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgotest.old
More file actions
57 lines (50 loc) · 1.02 KB
/
Copy pathgotest.old
File metadata and controls
57 lines (50 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
package main
import (
"fmt"
"io/ioutil"
"crypto/sha256"
"encoding/hex"
"bytes"
"bufio"
/*"os"*/
)
func checkFile(path string, fileName string) {
var buffer bytes.Buffer
buffer.WriteString(path)
buffer.WriteString("/")
buffer.WriteString(fileName)
h := sha256.New()
content, err := ioutil.ReadFile(buffer.String())
if err != nil {
}
h.Write(content)
fmt.Println(hex.EncodeToString(h.Sum(nil)))
var buffer bytes.Buffer
buffer.WriteString(path)
buffer.WriteString("/")
buffer.WriteString(fileName)
h := sha256.New()
if file, err = os.Open(buffer.String(); err != nil {
return
}
reader := bufio.NewReader(file)
buffer := bytes.NewBuffer(make([]byte, 1024))
for {
if part, prefix, err = reader.ReaderLine(); err != nil {
break
} else {
h.Write(part)
}
}
}
func main() {
dirList, err := ioutil.ReadDir("./save")
if err != nil {
}
for _, value := range dirList {
if value.IsDir() {
} else {
checkFile("./save",value.Name())
}
}
}