MCPcopy Index your code
hub / github.com/Tencent/CodeAnalysis / BlockMd5

Function BlockMd5

tools/owl/scan/scanner.go:109–132  ·  view source on GitHub ↗

BlockMd5 Built-in sharding md5 algorithm used

(file *os.File, size int64, hashed hash.Hash)

Source from the content-addressed store, hash-verified

107
108// BlockMd5 Built-in sharding md5 algorithm used
109func BlockMd5(file *os.File, size int64, hashed hash.Hash) (string, error) {
110 // Intercept data segment size window
111 var (
112 head = make([]byte, 500)
113 body = make([]byte, 24)
114 tail = make([]byte, 500)
115 )
116
117 if _, err := file.ReadAt(head, 0); err != nil {
118 return "", err
119 }
120
121 if _, err := file.ReadAt(body, size/4); err != nil {
122 return "", err
123 }
124
125 if _, err := file.ReadAt(tail, size-512); err != nil {
126 return "", err
127 }
128 hashed.Write(head)
129 hashed.Write(body)
130 hashed.Write(tail)
131 return hex.EncodeToString(hashed.Sum(nil)), nil
132}
133
134// HexDecode hex decryption
135func HexDecode(s string) []byte {

Callers 1

Md5Function · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected