core/zero: add usage reporter (#5281)

* wip

* add response

* handle empty email

* use set, update log

* add test

* add coalesce, comments, test

* add test, fix bug

* use builtin cmp.Or

* remove wait ready call

* use api error
This commit is contained in:
Caleb Doxsey 2024-09-12 15:45:54 -06:00 committed by GitHub
parent 82a9dbe42a
commit 146efc1b13
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
13 changed files with 697 additions and 2 deletions

View file

@ -0,0 +1,16 @@
package cryptutil
import (
"crypto/hmac"
"crypto/sha256"
"encoding/base64"
"io"
)
// Pseudonymize pseudonymizes data by computing the HMAC-SHA256 of the data.
func Pseudonymize(organizationID string, data string) string {
h := hmac.New(sha256.New, []byte(organizationID))
_, _ = io.WriteString(h, data)
bs := h.Sum(nil)
return base64.StdEncoding.EncodeToString(bs)
}