MCPcopy
hub / github.com/gofiber/fiber / makeHashAuthFunc

Function makeHashAuthFunc

middleware/cache/utils.go:138–163  ·  view source on GitHub ↗
(hexBufPool *sync.Pool)

Source from the content-addressed store, hash-verified

136}
137
138func makeHashAuthFunc(hexBufPool *sync.Pool) func([]byte) string {
139 return func(authHeader []byte) string {
140 sum := sha256.Sum256(authHeader)
141
142 v := hexBufPool.Get()
143 bufPtr, ok := v.(*[]byte)
144 if !ok || bufPtr == nil {
145 b := make([]byte, hexLen)
146 bufPtr = &b
147 }
148
149 buf := *bufPtr
150 if cap(buf) < hexLen {
151 buf = make([]byte, hexLen)
152 } else {
153 buf = buf[:hexLen]
154 }
155 *bufPtr = buf
156
157 hex.Encode(buf, sum[:])
158 result := string(buf)
159
160 hexBufPool.Put(bufPtr)
161 return result
162 }
163}

Callers 2

NewFunction · 0.85
Test_makeHashAuthFuncFunction · 0.85

Calls 2

GetMethod · 0.65
PutMethod · 0.65

Tested by 1

Test_makeHashAuthFuncFunction · 0.68