MCPcopy Create free account
hub / github.com/LagrangeDev/LagrangeGo / GetSha1Status

Function GetSha1Status

utils/crypto/hash.go:97–108  ·  view source on GitHub ↗
(h hash.Hash)

Source from the content-addressed store, hash-verified

95}
96
97func GetSha1Status(h hash.Hash) []byte {
98 if reflect.TypeOf(h).String() != "*sha1.digest" {
99 return nil
100 }
101 result := make([]byte, 20)
102 // 反射大法好
103 s := reflect.ValueOf(h).Elem().Field(0)
104 for i := 0; i < 5; i++ {
105 binary.LittleEndian.PutUint32(result[i*4:], uint32(s.Index(i).Uint()))
106 }
107 return result
108}

Callers 1

ComputeBlockSha1Function · 0.85

Calls 1

StringMethod · 0.45

Tested by

no test coverage detected