1
0
mirror of https://github.com/imgproxy/imgproxy.git synced 2024-11-24 08:12:38 +02:00
imgproxy/etag.go
2018-02-26 15:41:37 +06:00

21 lines
386 B
Go

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