Fix: Local ETag computation

This commit is contained in:
Daniel Hougaard
2024-06-12 02:10:35 +02:00
parent c3f7c1d46b
commit 32dd478894
+7
View File
@@ -3,6 +3,8 @@ package crypto
import ( import (
"crypto/aes" "crypto/aes"
"crypto/cipher" "crypto/cipher"
"fmt"
"hash/crc32"
"golang.org/x/crypto/nacl/box" "golang.org/x/crypto/nacl/box"
) )
@@ -33,3 +35,8 @@ func DecryptAsymmetric(ciphertext []byte, nonce []byte, publicKey []byte, privat
plainTextToReturn, _ := box.Open(nil, ciphertext, (*[24]byte)(nonce), (*[32]byte)(publicKey), (*[32]byte)(privateKey)) plainTextToReturn, _ := box.Open(nil, ciphertext, (*[24]byte)(nonce), (*[32]byte)(publicKey), (*[32]byte)(privateKey))
return plainTextToReturn return plainTextToReturn
} }
func ComputeEtag(data []byte) string {
crc := crc32.ChecksumIEEE(data)
return fmt.Sprintf(`W/"secrets-%d-%08X"`, len(data), crc)
}