1
0
mirror of https://github.com/imgproxy/imgproxy.git synced 2025-01-08 10:45:04 +02:00
imgproxy/etag.go

22 lines
439 B
Go

package main
import (
"crypto/sha256"
"encoding/binary"
"fmt"
)
var notModifiedErr = newError(304, "Not modified", "Not modified")
func calcETag(b []byte, po *processingOptions) string {
footprint := sha256.Sum256(b)
hash := sha256.New()
hash.Write(footprint[:])
hash.Write([]byte(version))
binary.Write(hash, binary.LittleEndian, conf)
binary.Write(hash, binary.LittleEndian, *po)
return fmt.Sprintf("%x", hash.Sum(nil))
}