mirror of
https://github.com/imgproxy/imgproxy.git
synced 2025-03-27 20:30:27 +02:00
23 lines
493 B
Go
23 lines
493 B
Go
package main
|
|
|
|
import (
|
|
"context"
|
|
"crypto/sha256"
|
|
"encoding/binary"
|
|
"fmt"
|
|
)
|
|
|
|
var notModifiedErr = newError(304, "Not modified", "Not modified")
|
|
|
|
func calcETag(ctx context.Context) []byte {
|
|
footprint := sha256.Sum256(getImageData(ctx).Bytes())
|
|
|
|
hash := sha256.New()
|
|
hash.Write(footprint[:])
|
|
hash.Write([]byte(version))
|
|
binary.Write(hash, binary.LittleEndian, conf)
|
|
binary.Write(hash, binary.LittleEndian, *getProcessingOptions(ctx))
|
|
|
|
return []byte(fmt.Sprintf("%x", hash.Sum(nil)))
|
|
}
|